Tikz 流程图

Tikz 流程图 首页 / Latex入门教程 / Tikz 流程图

流程图是概述算法的方法。它被广泛用于有效地表示信息。它是执行特定过程所需的步骤和决策的直观表示。

可以快速查看该过程,并且可以从头到尾遵循这些步骤。图或图表中使用的不同形状称为流程图符号。

同样,在Latex中,您可以使用某些命令在任何地方插入任何流程图或图表。

让我们通过一个例子来理解它。这里的主题将为您提供创建流程图的想法。您可以为图表创建类型和样式。

第一个图将为您提供简单流程图的基本概念,而第二个示例将为复杂流程图。

1。第一个示例的代码如下:

\documentclass{article}  
  
\usepackage{tikz} % the tikz package  
\usetikzlibrary{shapes.geometric,arrows} % to implement the corresponding shapes and arrows, these are used.  
\begin{document}  

    \title{How to learn flow diagrams using tikz} 
    \author{ Welcome learnfk.com } 
    \date{\today}
    \maketitle
      
%下面给出的命令用于定义特定块的样式

    \tikzstyle{block} = [rectangle, draw, fill=yellow!50,   
    text width=4.5em, text centered, rounded corners, minimum height=4em] % 宽度表示盒子的宽度。您可以相应地更改宽度,而高度将根据文本进行调整,它表示对于块部分,将使用矩形形状。可以修改颜色或形状。
    % 这里,距离是对应块之间的距离  
    \tikzstyle{line} = [draw, -latex']  
    \tikzstyle{cloud} = [draw, ellipse,text width= 2.9em, fill=red!50, node distance=2cm, minimum height=3em]  
% 值越大,颜色越深。
% 上面用宽度和颜色确定的形状只会进一步使用。
 \tikzstyle{io} = [trapezium, draw, trapezium right angle=110, rounded corners, fill=red!20, node distance=1.9cm, minimum height=2.9em]    
 % 这里的 draw 命令用于绘制提到的形状的边界。
% 您可以根据要求向 tikzstyle 添加更多参数。
    \begin{tikzpicture}[node distance = 1.8cm, auto] % 命令节点距离很重要,因为它决定了不同块之间的空间或箭头的长度。
        % 下面给出的命令是节点的位置
        \node [cloud] (init) {Start};  
        \node [io, below of= init](ReadLearn){Read Learn};  
        \node [io, below of= ReadLearn](ReadFk){Read Fk};  
        \node [block, below of = ReadFk](Sum){Sum = Learn+Fk};  
        \node [block, below of = Sum](P){Print Sum};  
        \node [cloud, below of = P](Out){End};  
        \path [line] (init) -- (ReadLearn);   
        \path [line] (ReadLearn) -- (ReadFk);   
        \path [line] (ReadFk) -- (Sum);   
        \path [line] (Sum) -- (P);   
        \path [line] (P) -- (Out);   
    \end{tikzpicture}  
\end{document}  

输出:

Latex Flow Diagrams using Tikz

2。第二个示例的代码如下:

\documentclass{article}  
  
\usepackage{tikz} % 引用 tikz 包  
\usetikzlibrary{shapes.geometric, arrows}   
\begin{document}  
     
\tikzstyle{decision} = [diamond, draw, fill=orange!80,   
    text width=5.0em, text centered, node distance=3.1cm,]   
    \tikzstyle{document} = [rectangle, draw, fill=blue!30,   
    text width=4.7em, text centered, node distance=2.5cm,]   
   \tikzstyle{block1} = [rectangle, draw, fill=green!50,  %在这里,我们为不同的颜色选择了另一个块
    text width=4.5em, text centered, rounded corners, node distance= 3cm, minimum height=3em] % 您可以根据要求创建尽可能多的不同形状,使您的图表更具创意和吸引力
\tikzstyle{block} = [rectangle, draw, fill=yellow!50,   
    text width=4.5em, text centered, rounded corners, node distance=2.25cm, minimum height=4em]  
\tikzstyle{line} = [draw, -latex']  
\tikzstyle{cloud} = [draw, ellipse,text width= 2.9em, fill=red!50, node distance=2cm, minimum height=3em]  
  
\tikzstyle{ioi} = [trapezium, draw, trapezium right angle=120,rounded corners, fill=blue!60, node distance=2.8cm, minimum height=2.7em]  
 \tikzstyle{io} = [trapezium, draw, trapezium right angle=110,rounded corners, fill=red!20, node distance=1.9cm, minimum height=2.9em]   % 这里的 draw 命令用于绘制提到的形状的边界。 
\begin{tikzpicture}[node distance = 1.8cm, auto] % 命令节点距离很重要,因为它决定了不同块之间的空间或箭头的长度。
    %下面给出的命令是节点的位置
    \node [cloud] (init) {Start};  
    \node [io, below of=init](A){Step A};  
    \node [io, below of=A](B){Step B};  
    \node [block, below of = B](C){Step C};  
    \node [block, below of = C](D){Step D};  
    \node [decision, below of = D](E){Step LearnFK};  
    \node [document, below of = E](F){Step F};  
    \node [cloud, below of = F](G){Step G};  
    \node [block1, right of = D](H){Step H};  
    \node [ioi, below of = H](I){Step I};  
    \node [decision, left of = D](J){Step J};  
    \node [ioi, below of = J](K){Step K};  
    \path [line] (init) -- (A);   
    \path [line] (A) -- (B);   
    \path [line] (B) -- (C);   
    \path [line] (C) -- (D);   
    \path [line] (D) -- (E);   
    \path [line] (E) -- (F);   
    \path [line] (F) -- (G);   
    \path [line] (D) -- (H);   
    \path [line] (H) -- (I);   
    \path [line] (I) |- (G.east); % |- 用于制作矩形箭头
    \path [line] (C) |- (J.north); % 要定位箭头,您可以使用北、南、东和西方向
    \path [line] (J) -- (K);   
    \path [line] (K) |- (F.west);   
    \path [line, dashed] (H) |- (init.east); % 虚线命令用于创建虚线
      
\end{tikzpicture}  
\end{document}  

输出:

Latex Flow Diagrams using Tikz

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

朱赟的技术管理课 -〔朱赟〕

iOS开发高手课 -〔戴铭〕

零基础学Java -〔臧萌〕

Java性能调优实战 -〔刘超〕

深入浅出云计算 -〔何恺铎〕

高楼的性能工程实战课 -〔高楼〕

如何读懂一首诗 -〔王天博〕

程序员的测试课 -〔郑晔〕

AI大模型之美 -〔徐文浩〕

好记忆不如烂笔头。留下您的足迹吧 :)