当前位置: 首页 > news >正文

latex中三种画流程图的方式

第一种:使用tikzpicture
\documentclass[UTF8]{ctexart}
\usepackage{tikz,mathpazo}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}\thispagestyle{empty}% 流程图定义基本形状\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm,text centered, draw=black, fill=red!30]\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=orange!30]\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]\tikzstyle{arrow} = [thick,->,>=stealth]\begin{tikzpicture}[node distance=2cm]%定义流程图具体形状对象\node (start) [startstop] {Start};\node (in1) [io, below of=start] {Input1};\node (in2) [io, right of=in1, xshift=3.5cm] {Input2};\node (pro1) [process, below of=in1] {Process 1};\node (dec1) [decision, below of=pro1, yshift=-0.5cm] {Decision 1};\node (pro2a) [process, below of=dec1, yshift=-0.5cm] {Process 2a};\node (pro2b) [process, right of=dec1, xshift=3cm] {Process 2b};\node (out1) [io, below of=pro2a] {Output};\node (stop) [startstop, below of=out1] {Stop};%连接具体形状连接关系\draw [arrow](start) -- (in1);\draw [arrow](in1) -- (in2);\draw [arrow](in1) -- (pro1);\draw [arrow](pro1) -- (dec1);\draw [arrow](dec1) -- (pro2a);\draw [arrow](dec1) -- (pro2b);\draw [arrow](in2) -- (pro2b);\draw [arrow](dec1) -- node[anchor=east] {yes} (pro2a);\draw [arrow](dec1) -- node[anchor=south] {no} (pro2b);\draw [arrow](pro2b) |- (pro1);\draw [arrow](pro2a) -- (out1);\draw [arrow](out1) -- (stop);\end{tikzpicture}
\end{document}

第二种:使用tikzpicture和flowchart

\documentclass[UTF8]{ctexart}
\usepackage{tikz,mathpazo}
\usetikzlibrary{shapes.geometric, arrows}
\usepackage{flowchart}
\begin{document}\begin{tikzpicture}[font={\sf \small}]\def \smbwd{2cm}\thispagestyle{empty}%定义流程图的具体形状\node (start) at (0,0) [draw, terminal,minimum width=\smbwd, minimum height=0.5cm] {开始}; % 定义开始 \node (getdata) at (0,-1.5) [draw, predproc, align=left,minimum width=\smbwd,minimum height=1cm] {读取数据}; %定义预处理过程,读取数据\node (decide1) at (0,-3.5) [draw, decision, minimum width=\smbwd, minimum height=1cm] {判断条件1}; %定义判断条件\node (process1) at (3,-4.25) [draw, process, minimum width=\smbwd, minimum height=0.5cm] {处理过程1}; %定义处理过程\node (decide2) at (0,-6.5) [draw, decision, minimum width=\smbwd, minimum height=1cm] {判断条件2}; %定义数据存储\node (process2) at (3,-7.25) [draw, process, minimum width=\smbwd, minimum height=0.5cm] {处理过程2}; %定义处理过程\node (decide3) at (0,-9.5) [draw, decision, minimum width=\smbwd, minimum height=1cm] {判断条件3}; %定义数据存储\node (process3) at (3,-10.25) [draw, process, minimum width=\smbwd, minimum height=0.5cm] {处理过程3}; %定义处理过程\node (storage) at (3,-11.75) [draw, storage, minimum width=\smbwd, minimum height=0.5cm] {数据存储}; %定义数据存储\coordinate (point1) at (0,-5);\coordinate (point2) at (0,-8);\coordinate (point3) at (0,-11.75);\node (end) at (0,-12.75) [draw, terminal,minimum width=\smbwd,minimum height=0.5cm] {结束}; %定义结束%连接定义的形状,绘制流程图--表示垂直线,|表示箭头方向\draw[->] (start) -- (getdata);\draw[->] (getdata)-- (decide1);\draw[->] (decide1) -| node[above]{成立} (process1);\draw[->] (process1) |- (point1);\draw[->] (decide1)-- node[left]{否}(decide2);\draw[->] (decide2) -| node[above]{成立} (process2);\draw[->] (process2) |- (point2);\draw[->] (decide2)-- node[left]{否}(decide3);\draw[->] (decide3) -| node[above]{成立} (process3);\draw[->] (process3) -- (storage);\draw[->] (storage) -- (point3);\draw[->] (decide3) -- node[left]{否}(point3) -- (end);\end{tikzpicture}
\end{document}

第三种:pgf-tik文档中的官方例程,将所有元素按照矩阵排列,接着使用path标注路径;

\documentclass[UTF8]{ctexart}
\usepackage{tikz,mathpazo}
\usetikzlibrary {arrows,shapes.geometric}
\begin{document}
\begin{tikzpicture}[auto,decision/.style={diamond, draw=blue, thick, fill=blue!20,text width=4.5em,align=flush center,inner sep=1pt},block/.style={rectangle, draw=blue, thick, fill=blue!20,text width=5em,align=center, rounded corners,minimum height=4em},line/.style={draw, thick, -latex',shorten >=2pt},cloud/.style={draw=red, thick, ellipse,fill=red!20,minimum height=2em}]\matrix [column sep=5mm,row sep=7mm]{% row 1\node [cloud] (expert){expert}; &\node [block] (init){initialize model}; &\node [cloud] (system){system}; \\% row 2& \node [block] (identify) {identify candidate model}; & \\% row 3\node [block] (update){update model}; &\node [block] (evaluate) {evaluate candidate models}; & \\% row 4& \node [decision] (decide) {is best candidate}; & \\% row 5& \node [block] (stop){stop}; & \\};\begin{scope}[every path/.style=line]\path    (init)-- (identify);\path    (identify) -- (evaluate);\path    (evaluate) -- (decide);\path    (update)|- (identify);\path    (decide)-| node [near start] {yes} (update);\path    (decide)-- node [midway] {no} (stop);\path [dashed] (expert)-- (init);\path [dashed] (system)-- (init);\path [dashed] (system)|- (evaluate);\end{scope}
\end{tikzpicture}
\end{document}

个人觉得第一种实现最简单,但是完全自动排版,不够灵活;第三种,逻辑简单,排版灵活强大;第二种基于flowchart使用限制较多,排版不够灵活,功能也一般,不建议使用。

http://www.rkmt.cn/news/1524892.html

相关文章:

  • 影刀RPA新手教程_抖音数据监控实战关键词搜索视频数据采集与趋势追踪
  • 《鸿蒙原生应用开发实战》第五篇:收藏功能、资源管理与构建发布
  • 昆明奢侈品回收市场深度调研:3家实体门店实测,2026年6月最新行情与交易指南 - 钦扬网络
  • 2026最新英语写作批改AI系统 核心功能及使用避坑指南汇总
  • 2026年驻马店市PMP培训机构哪家好?官方授权R.E.P.报考指南 - 众智商学院课程中心
  • 突破局部逻辑的枷锁:现代 C++ Lambda 表达式的演进与闭包艺术
  • 3个简单步骤让BongoCat音效系统彻底改变你的桌面互动体验
  • 2026深圳龙岗宝安龙华黄金回收实测:全城11区免费上门,30分钟响应当场结算 - 逸程
  • 2026最新 英语老师亲测推荐适合学生用的优质英语听力APP
  • 逆向工程实战:如何打造你自己的微信QQ防撤回补丁
  • 昆明奢侈品回收指南:3家实体门店实地测评,2026年6月最新行情 - 钦扬网络
  • BiliBili-Manga-Downloader:跨平台漫画下载解决方案的技术架构与实践指南
  • 影刀RPA新手教程_网页表格数据提取完全指南HTML表格到Excel的标准流程
  • 揭阳管道疏通马桶疏通 口碑甄选服务商合集|2026 本地推荐指南 - 金修达家庭维修
  • 捕捉时间的切片:4D 高斯溅射如何让“全息视频”成为现实
  • 高效歌词同步工具LRCGET:如何10分钟内为数千首音乐批量下载精准歌词?
  • 2026深圳福田CBD黄金回收行情速递:大盘价减5元/克 - 逸程
  • 如何实现3步实时人脸替换:Deep-Live-Cam完整指南
  • ATM反向复用技术原理与MPC8323E IMA模块配置实战
  • 2026年最新可布置作业的英语教学软件 老师选款实用指南
  • 青岛名包回收口碑排名 本地 6 家门店实测盘点 - 讯息早知道
  • 3分钟学会AI图像超分辨率:让模糊照片变清晰的终极方案
  • caj2pdf-qt:解决CAJ文件阅读难题的专业转换方案
  • 如何快速搭建个人数字图书馆:Open Library完整开源解决方案指南
  • 【共创季稿事节】鸿蒙原生 ArkTS 布局精讲:foregroundColor 前景色统一着色
  • 2026 东莞代理记账公司推荐榜 广东万创实力领先 注册公司/进出口退税/合规财税/内账外包服务实力机构 TOP 推荐 - 变量人生001
  • 2026年众智商学院官网怎么找、400电话怎么拨打、冯老师微信怎么加、课程怎么报名 - 众智商学院官方
  • Sunshine游戏串流终极指南:为什么你应该立即搭建自己的云游戏服务器
  • 2026年众智商学院PMP题库资料怎么领取?报名费用35学时班期和报考指导怎么确认,冯老师 - 众智商学院职业教育
  • MPC8540 L1缓存与MMU寄存器实战:从原理到调试的嵌入式开发指南