流程图 tikz 节点和形状

流程图 tikz 节点和形状

我正在尝试复制以下流程图在此处输入图片描述

使用以下代码:

\documentclass[border=10pt]{standalone}
 \usepackage{tikz}
 \usetikzlibrary{shapes.geometric, arrows}

  \tikzstyle{startstop} = [rectangle, 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{document}

   \begin{tikzpicture}[node distance=2cm]

    \node (start) [startstop] {Planning};
   \node (in1) [startstop, below of=start] {Input};
   \node (pro1) [process, below of=in1] {Process 1};
   \node (pro2) [process, below of=pro1] {Decision 1};
   \node (dec1) [decision, below of=pro2, yshift=-0.5cm] {Decision 1};
   \node (dec2) [decision, below of=dec1, yshift=-1cm] {Decision 2};

  \draw [arrow] (start) -- (in1);
  \draw [arrow] (in1) -- (pro1);
  \draw [arrow] (pro1) -- (pro2);
   \draw [arrow] (pro2) -- (dec1);
   \draw [arrow] (dec1) -- (dec2);

  \end{tikzpicture}

 \end{document}

但是,我无法设置节点来以多行写入,绘制菱形并使用文本“是”或“否”制作适当的连接器。

我应该使用任何其他设置和配置吗?

在此先感谢您的帮助。

答案1

将连接添加到您的代码非常简单,无需切换设备。更新:添加了文本宽度和一些示例文本{\Huge BIG THANKS $\to$ @Zarko}

\documentclass[border=10pt]{standalone}
 \usepackage{tikz}
 \usetikzlibrary{shapes.geometric, arrows,positioning}

  \tikzstyle{startstop} = [rectangle, text width=3cm, minimum   height=1cm,text centered, draw=black, fill=red!30]
   \tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right 
   angle=110, text width=3cm, minimum height=1cm, text centered, draw=black, fill=blue!30]
   \tikzstyle{process} = [rectangle, text width=3cm, minimum height=1cm,    text centered, draw=black, fill=orange!30]
   \tikzstyle{decision} = [diamond, text width=3cm, minimum height=1cm, text centered, draw=black, fill=green!30]
   \tikzstyle{arrow} = [thick,->,>=stealth]


   \begin{document}

   \begin{tikzpicture}[node distance=0.8cm,font=\sf]

    \node (start) [startstop] {\textbf{Planning}: To identify and define the
    needs for production.};
   \node (in1) [startstop, below=of start] {\textbf{Input}: Task
   distribution\dots};
   \node (pro1) [process, below=of in1] {Process 1};
   \node (pro2) [process, below=of pro1] {Decision 1};
   \node (dec1) [decision, below=of pro2] {Are we achieving the targets?};
   \node (dec2) [decision, below=of dec1] {Decision 2};

  \draw [arrow] (start) -- (in1);
  \draw [arrow] (in1) -- (pro1);
  \draw [arrow] (pro1) -- (pro2);
   \draw [arrow] (pro2) -- (dec1);
   \draw [arrow] (dec1) -- (dec2);
   %new
   \draw [arrow,-] (dec1.west) -- ++(-1,0) node[midway,above]{yes} |- (pro2.west);
   \draw [arrow,-] (dec2.west) -- ++(-2,0) node[midway,above]{yes} |- (pro1.west);
   \draw [arrow] (dec2.east) -- ++(2,0) node[midway,above]{no} coordinate (right)|- (start.east);
   \draw [arrow] (right|-in1) -- (in1.east);
   \draw [arrow,dashed] (pro2.east) -- ++(1,0) coordinate(almostright) |- (start.-10);
   \draw [arrow,dashed] (almostright|-in1.-10) -- (in1.-10);

  \end{tikzpicture}

 \end{document}

在此处输入图片描述

相关内容