h2457528767的个人博客分享 http://blog.sciencenet.cn/u/h2457528767

博文

Tikz 绘制流程图

已有 4544 次阅读 2020-8-20 20:59 |个人分类:软件学习|系统分类:科研笔记| latex, tikz

效果图:

flow_chart_simple.png

代码:

\documentclass{article}
\usepackage{amsthm,amsmath,amssymb}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{positioning, shapes.geometric}
\usetikzlibrary{calc}
% Define the basic shape of flow chart
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width = 2cm, minimum height=1cm,text centered, draw = black, fill = red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill = blue!25]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill = yellow!35]
\tikzstyle{decision} = [diamond, aspect = 3, text centered, minimum width = 2.5cm, draw=black, fill = green!45]% arrow shape
\tikzstyle{arrow} = [->,>=stealth]
\usepackage[active,pdftex,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength{\PreviewBorder}{0.5bp}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[node distance = 1.2cm]
  % Define flowchart  shape
  \node (start) [startstop] {Start};
  \node (in1) [io, below of = start, yshift=-0.2cm, minimum width=1cm] {Input};  \node (dec1) [decision, below of=in1, yshift=-0.2cm] {cycle 1};
  \node (pro1) [process, below of=dec1,yshift=-0.2cm] {process 1};
  \node (dec2) [decision, below of=pro1, yshift=-0.2cm] {cycle 2};
  \node (pro2) [process, below of=dec2,yshift=-0.2cm] {Process 2};
  \node (pro3) [process, below of=pro2,yshift=-0.2cm] {Process 3};
  \node (pro4) [process, below of=pro3,yshift=-0.2cm] {Process 4};
  \node (in2)  [io, below of=pro4, yshift=-0.2cm] {Output};
  \node (stop) [startstop, below of=in2,node distance = 1.6cm] {End};
  % connect
  \draw[arrow] (start)  -- (in1);
  \draw[arrow] (in1) -- (dec1);
  \draw[arrow] (dec1.west)-- node[anchor=south] {N} ($(dec1.west) - (1.3,0)$) |- ($(stop.north)!.3!(in2.south)$) -- (stop);
  \draw[arrow] (dec1) -- node[anchor=west] {Y} (pro1);
  \draw[arrow] (pro1) -- (dec2);
  \draw[arrow] (dec2.east) -- node[anchor=south] {N} ($(dec2.east) + (1.3,0)$) |- ($(in1.south)!.5!(dec1.north)$);
  \draw[arrow] (dec2) -- node[anchor=west] {Y} (pro2);
  \draw[arrow] (pro2) -- (pro3);
  \draw[arrow] (pro3) -- (pro4);
  \draw[arrow] (pro4) -- (in2);
  \draw[arrow] (in2.south)  -- ($(in2.south)-(0,0.2)$) -- ($(in2.south) - (2.2,0.2)$) |- ($(pro1.south)!.5!(dec2.north)$);
\end{tikzpicture}
\caption{The flowchart}\label{fig:flowchart}
\end{figure}
\end{document}

作者:李金磊

转载或使用请联系作者授权,谢谢!



https://blog.sciencenet.cn/blog-3398164-1247196.html

上一篇:如何在Inkscape图中输入LaTeX公式?
下一篇:LaTeX如何插入作者的ORCID
收藏 IP: 202.111.182.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-20 08:50

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部