tikz 中的流程图

tikz 中的流程图

我对 tikz 软件包完全陌生,想构建如图所示的流程图。我尝试过几次,但都没有成功。您能给我一些提示,教我如何开始制作这样的流程图吗?提前谢谢,Marcin在此处输入图片描述

答案1

看看这是否适合你。核心是命令,(n1-|n2)意思是“点 n2 投影在通过 n1 的水平线上”,因此你可以将中间步骤设置为流程图样式。

\documentclass[border=5mm]{standalone}

\usepackage{tikz}
    \usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}
        \node[rectangle, draw, minimum width=12mm, minimum height=7mm] (n1) at (0, 0) {n1};
        \node[rectangle, draw] (n2) at ($(n1) + (1, 2)$) {n2};
        \node[rectangle, draw, minimum width=15mm, minimum height=3mm] (n3) at ($(n2) + (1, 2)$) {n3};
        \node[rectangle, draw] (n4) at ($(n2) + (1, -1)$) {n4};
        \node[rectangle, draw] (n5) at ($(n4) + (2, 0)$) {n5};
        \draw (n1) to (n1-|n2) to (n2);
        \draw (n2) to (n2-|n3) to (n3);
        \draw (n2) to (n2-|n4) to (n4);
        \draw (n4) to (n5);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

最后,感谢您的支持,我解决了这个问题。这是我的答案的解决方案的代码。

\documentclass[border=5mm]{standalone}

\usepackage{tikz}
    \usetikzlibrary{calc}


\begin{document}

\scalebox{0.52}{
 \begin{tikzpicture}
    [
    mynode/.style={rectangle, draw, align=center, text width =3cm ,minimum width=3cm, minimum height=1cm}
]
    \node[mynode] (a) at ($(0, 0)$) {Text 1};
    \node[mynode] (b1) at ($(a) + (4, 3.5)$) {Text 2};
    \node[mynode] (b2) at ($(a) + (4,-2.1)$) {Text 3};
    \node[mynode] (b3) at ($(a) + (4,-3.5)$) {Text 4};
    \node[mynode] (c1) at ($(a) + (8,4.2)$) {Text 5};
    \node[mynode] (c2) at ($(a) + (8,2.8)$) {Text 6};
    \node[mynode] (c3) at ($(a) + (8,1.4)$) {Text 7};
    \node[mynode] (c4) at ($(a) + (8,-5.6)$) {Text 8};
    \node[mynode] (d1) at ($(a) + (12,3.5)$) {Text 9};
    \node[mynode] (d2) at ($(a) + (12,-0.7)$) {Text 10};
    \node[mynode] (d3) at ($(a) + (12,-4.9)$) {Text 11};
    \node[mynode] (d4) at ($(a) + (12,-6.3)$) {Text 12};
    \node[mynode] (e1) at ($(a) + (16,4.9)$) {Text 13};
    \node[mynode] (e2) at ($(a) + (16,3.5)$) {Text 14};
    \node[mynode] (e3) at ($(a) + (16,2.1)$) {Text 15};
    \node[mynode] (e4) at ($(a) + (16,0.7)$) {Text 16};
    \node[mynode] (e5) at ($(a) + (16,-0.7)$) {Text 17};
    \node[mynode] (e6) at ($(a) + (16,-2.1)$) {Text 18};
    \node[mynode] (e7) at ($(a) + (16,-3.5)$) {Text 19};
    \node[mynode] (e8) at ($(a) + (16,-6.3)$) {Text 20};
    \node[mynode] (f1) at ($(a) + (20,-2.8)$) {Text 21};
    \node[mynode] (f2) at ($(a) + (20,-4.2)$) {Text 22};
    \node[mynode] (f3) at ($(a) + (20,-5.6)$) {Text 23};
    \node[mynode] (f4) at ($(a) + (20,-7)$) {Text 24};

    \draw (a) -| ($(a)!.5!(b1)$) |- (b1);
    \draw (a) -| ($(a)!.5!(b2)$) |- (b2);
    \draw (a) -| ($(a)!.5!(b3)$) |- (b3);
    \draw (b1) -| ($(b1)!.5!(c1)$) |- (c1);
    \draw (b1) -| ($(b1)!.5!(c2)$) |- (c2);
    \draw (b2) -| ($(b2)!.5!(c3)$) |- (c3);
    \draw (b2) -| ($(b2)!.5!(c4)$) |- (c4);
    \draw (c3) -| ($(c3)!.5!(d1)$) |- (d1);
    \draw (c3) -| ($(c3)!.5!(d2)$) |- (d2);
    \draw (c4) -| ($(c4)!.5!(d3)$) |- (d3);
    \draw (c4) -| ($(c4)!.5!(d4)$) |- (d4);
    \draw (d1) -| ($(d1)!.5!(e1)$) |- (e1);
    \draw (d1) -| ($(d1)!.5!(e2)$) |- (e2);
    \draw (d1) -| ($(d1)!.5!(e3)$) |- (e3);
    \draw (d2) -| ($(d2)!.5!(e4)$) |- (e4);
    \draw (d2) -| ($(d2)!.5!(e5)$) |- (e5);
    \draw (d2) -| ($(d2)!.5!(e6)$) |- (e6);
    \draw (d3) -| ($(d3)!.5!(e7)$) |- (e7);
    \draw (d3) -| ($(d3)!.5!(e8)$) |- (e8);
    \draw (e7) -| ($(e7)!.5!(f1)$) |- (f1);
    \draw (e7) -| ($(e7)!.5!(f2)$) |- (f2);
    \draw (e8) -| ($(e8)!.5!(f3)$) |- (f3);
    \draw (e8) -| ($(e8)!.5!(f4)$) |- (f4);
\end{tikzpicture}
}
\end{document}

哪个输出是

在此处输入图片描述

相关内容