当前位置: 首页 > 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.jsqmd.com/news/1013070/

相关文章:

  • 2026年柳州市PMP培训机构哪家好?官方授权R.E.P.报考指南 - 众智商学院课程中心
  • 昆明奢侈品回收市场深度调研:3家实体门店实测,2026年6月最新行情与交易指南 - 钦扬网络
  • 深入解析PowerPC e500核心微架构:流水线、分支预测与中断实战
  • MPC8272 FCC缓冲区描述符与参数RAM:嵌入式通信的“交通指挥官”
  • 2026年驻马店市PMP培训机构哪家好?官方授权R.E.P.报考指南 - 众智商学院课程中心
  • 2026最新英语写作批改AI系统 核心功能及使用避坑指南汇总
  • 2026年莆田市PMP培训机构哪家好?官方授权R.E.P.报考指南 - 众智商学院课程中心
  • Deceive终极指南:三步实现游戏隐身,享受专属游戏时光
  • 终极指南:3步掌握Switch文件解析神器hactool
  • 2026深圳华强北黄金回收避坑指南:虚高报价+鬼秤缩水+恶意压纯度,三大套路逐一拆解 - 逸程
  • 锅炉蒸汽温度温度控制系统 模糊控制 simulink仿真3 (设计源文件+万字报告+讲解)(支持资料、图片参考_相关定制)_文章底部可以扫码
  • 影刀RPA新手教程_条件判断与分支逻辑从入门到工程级实战
  • 2026年众智商学院PMP加微信咨询怎么获取试听课?1980元费用35学时班期和题库资料确认 - 众智商学院官方
  • 2026 宁波天然 A 货翡翠全面回收,手镯吊坠摆件等藏品都可预约上门估价 - 薛定谔的梨花猫
  • 突破局部逻辑的枷锁:现代 C++ Lambda 表达式的演进与闭包艺术
  • 终极AutoHotkey v2转换指南:如何快速完成v1脚本升级的完整方法
  • 告别模糊:用Real-ESRGAN-GUI轻松实现图片高清修复的完整指南
  • 3个简单步骤让BongoCat音效系统彻底改变你的桌面互动体验
  • 2026深圳龙岗宝安龙华黄金回收实测:全城11区免费上门,30分钟响应当场结算 - 逸程
  • 联想拯救者工具箱终极指南:如何快速掌握笔记本性能调优的10个秘籍
  • MPC8540 PowerQUICC III处理器:L2缓存与片上网络架构深度解析
  • 2026最新 英语老师亲测推荐适合学生用的优质英语听力APP
  • PowerQUICC II SMC与MCC控制器深度解析:从GCI协议到多通道HDLC实战
  • 逆向工程实战:如何打造你自己的微信QQ防撤回补丁
  • 基于微服务架构的高性能数据可视化解决方案:AJ-Report技术深度解析
  • 昆明奢侈品回收指南:3家实体门店实地测评,2026年6月最新行情 - 钦扬网络
  • 深入解析PCI总线时序与MPC8323E控制器实战应用
  • 计算机Java毕设实战-基于 SpringBoot 的社区物业报修与设备维护管理系统 面向智慧小区的物业报修运维服务系统【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • BiliBili-Manga-Downloader:跨平台漫画下载解决方案的技术架构与实践指南
  • 2026年6月设备外壳公司推荐,耐磨损性能佳,长久使用依然如新 - 品牌推荐师