• Tikz 绘制 flowchart 流程图


    效果(Result):

    flow_chart_simple

    代码如下(The code is shown as follows):

    documentclass{article}
    usepackage{amsthm,amsmath,amssymb}
    usepackage{amsfonts}
    usepackage{tikz}
    usetikzlibrary{positioning, shapes.geometric}
    usetikzlibrary{calc}
    
    % Define the basic shape of flow chart
    	ikzstyle{startstop} = [rectangle, rounded corners, minimum width = 2cm, minimum height=1cm,text centered, draw = black, fill = red!30]
    	ikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=2cm, minimum height=1cm, text centered, draw=black, fill = blue!25]
    	ikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, text centered, draw=black, fill = yellow!35]
    	ikzstyle{decision} = [diamond, aspect = 3, text centered, minimum width = 2.5cm, draw=black, fill = green!45]
    % arrow shape
    	ikzstyle{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
      
    ode (start) [startstop] {Start};
      
    ode (in1) [io, below of = start, yshift=-0.2cm, minimum width=1cm] {Input};
      
    ode (dec1) [decision, below of=in1, yshift=-0.2cm] {cycle 1};
      
    ode (pro1) [process, below of=dec1,yshift=-0.2cm] {process 1};
      
    ode (dec2) [decision, below of=pro1, yshift=-0.2cm] {cycle 2};
      
    ode (pro2) [process, below of=dec2,yshift=-0.2cm] {Process 2};
      
    ode (pro3) [process, below of=pro2,yshift=-0.2cm] {Process 3};
      
    ode (pro4) [process, below of=pro3,yshift=-0.2cm] {Process 4};
      
    ode (in2)  [io, below of=pro4, yshift=-0.2cm] {Output};
      
    ode (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}

    若要输出的 pdf 不含白边,则在导言区加入如下代码:

    usepackage[active,pdftex,tightpage]{preview}
    PreviewEnvironment{tikzpicture}
    %set the size of white edge
    setlength{PreviewBorder}{0.5bp}

    作者:李金磊

    邮箱:lijinlei0907@163.com

    如需转载或使用请务必联系作者授权!本人保留追究未经授权使用者法律责任的权利!

  • 相关阅读:
    CSS书写技巧(转)
    OutputCache祥解
    [推荐/译文/转]从底层角度看ASP.NETA lowlevel Look at the ASP.NET Architecture
    [转]ASP.NET页面解析
    .NET开发中你可能会用到的常用方法总结
    asp.net 页面清除缓存
    ASP.NET内部原理(HttpHandler和HttpModule)
    .NET开发中你可能会用到的常用方法总结(2)
    C#解析HTML
    如何理解IIS 7的两种应用程序池的管道模式(Managed Pipeline Mode)
  • 原文地址:https://www.cnblogs.com/Jin-Lei-Li/p/13537464.html
Copyright © 2020-2023  润新知