但我只能画出下面的图:
我无法精确控制标签的位置,也不知道如何画一个从一个节点到另一个节点中间的箭头;如何在标签之间画线(标签之间左边的红线)。而且这个流程图看起来不美观,谁有更美观的流程图示例?
\documentclass[tikz,border=2pt]{standalone}
\usepackage{inputenc}
\usetikzlibrary{positioning,chains}
\usetikzlibrary{shapes,arrows,matrix,scopes}
\begin{document}
\begin{tikzpicture}
[auto,
decision/.style={rectangle, draw=blue, thick, fill=blue!20,text width=5.2em, text centered, rounded corners,minimum height=1.2em},
block/.style={rectangle, draw=blue, thick, fill=blue!20,text width=10.2em, text centered, rounded corners,minimum height=1.2em},
block1/.style={rectangle, draw=blue, thick, fill=blue!20,text width=11.2em, text centered, rounded corners,minimum height=1.2em},
line/.style={draw, thick, -latex', shorten >=2pt},
cloud/.style={rectangle, draw=red, thick, fill=red!20,text width=1.2em, text centered, rounded corners,minimum height=4.2em}]
\matrix [column sep=5mm,row sep=5mm,ampersand replacement=\&]
{
% row 1
\& \node [block] (r1){abcdefghi}; \& \\
% row2
\node [block] (r21){abcd}; \&
\node [decision] (r22){abcdef}; \&
\node [decision] (r23){abcdefg}; \\
% row 3
\node [block] (r31) {abcdefgh}; \&
\node [decision] (r32) {abcdefghijkl}; \&
\node [decision] (r33) {abcdegfhij}; \&\\
% row 4
\node [block] (r4){abcedef}; \&\\
% row 5
\node [block] (r5) {abcdefgh}; \& \\
% row 6
\node [block] (r6) {abvdfasdfsdfdsafsadf}; \& \\
% row 7
\& \hspace{-3em} \node [block1] (r7){sdfsdfsdfs}; \& \\
% row 8
\node [block] (r8){dfassdfsdf}; \& \\
% row 9
\node [block] (r9){dfsdfsdf}; \& \\
% row 10
\node [block] (r10){dsfasdf}; \& \\
};
\begin{scope}[every path/.style=line]
\path (r1)-- (r21);
\path (r1)-- (r22);
\path (r1)-- (r23);
\path (r21)-- (r31);
\path (r22)-- (r32);
\path (r23)-- (r33);
\path (r31)-- (r4);
\path (r4)-- (r5);
\path (r5)--node[right]{abce} (r6);
\path (r6)-- (r8);
\path (r8)-- (r9);
\path (r9)-- (r10);
\path (r5)-| node[near end]{bded} (r32);
\end{scope}
% the labels on the left
\begin{scope}[node distance=7mm]
\node[cloud,below left=-50mm of r1.north west]{a\\b};
\node[cloud,below left=-50mm and 11mm of r31.north west]{a\\b\\d\\d};
\node[cloud,below left=-50mm and 11mm of r6.north west]{a\\e\\f\\g\\h};
\node[cloud,below left=-50mm and 11mm of r9.north west]{a\\b\\c\\d};
\end{scope}
\end{tikzpicture}
\end{document}
答案1
尝试理解以下解决方案。这只是一种可能性。
\path (r7)->(r7-|r6); %<---- New line
从 到和中心r7
之间的交点画一条线。r7
r6
\node[cloud, above left=0mm and 7mm of r21.south west] (ab) {a\\b};
r21.south west
使用south east
(由于above left
)作为节点锚点,在左侧 7 毫米处绘制一个云节点。
\node[cloud] at (ab|-r4) (abdd) {a\\b\\d\\d};
如果你理解了第一个,这个就很容易了。
对于红线,稍微玩一下直到获得所需的结果:
\draw[thick, red] ([shift={(3mm,-2mm)}]ab.south east)--+(180:13mm);
这是完整的代码:
\documentclass[tikz,border=2pt]{standalone}
\usepackage{inputenc}
\usetikzlibrary{positioning,chains}
\usetikzlibrary{shapes,arrows,matrix,scopes}
\begin{document}
\begin{tikzpicture}
[auto,
decision/.style={rectangle, draw=blue, thick, fill=blue!20,text width=5.2em, text centered, rounded corners,minimum height=1.2em},
block/.style={rectangle, draw=blue, thick, fill=blue!20,text width=10.2em, text centered, rounded corners,minimum height=1.2em},
block1/.style={rectangle, draw=blue, thick, fill=blue!20,text width=11.2em, text centered, rounded corners,minimum height=1.2em},
line/.style={draw, thick, -latex', shorten >=2pt},
cloud/.style={rectangle, draw=red, thick, fill=red!20,text width=1.2em, text centered, rounded corners,minimum height=4.2em}]
\matrix [column sep=5mm,row sep=5mm,ampersand replacement=\&]
{
% row 1
\& \node [block] (r1){abcdefghi}; \& \\
% row2
\node [block] (r21){abcd}; \&
\node [decision] (r22){abcdef}; \&
\node [decision] (r23){abcdefg}; \\
% row 3
\node [block] (r31) {abcdefgh}; \&
\node [decision] (r32) {abcdefghijkl}; \&
\node [decision] (r33) {abcdegfhij}; \&\\
% row 4
\node [block] (r4){abcedef}; \&\\
% row 5
\node [block] (r5) {abcdefgh}; \& \\
% row 6
\node [block] (r6) {abvdfasdfsdfdsafsadf}; \& \\
% row 7
\& \hspace{-3em} \node [block1] (r7){sdfsdfsdfs}; \& \\
% row 8
\node [block] (r8){dfassdfsdf}; \& \\
% row 9
\node [block] (r9){dfsdfsdf}; \& \\
% row 10
\node [block] (r10){dsfasdf}; \& \\
};
\begin{scope}[every path/.style=line]
\path (r1)-- (r21);
\path (r1)-- (r22);
\path (r1)-- (r23);
\path (r21)-- (r31);
\path (r22)-- (r32);
\path (r23)-- (r33);
\path (r31)-- (r4);
\path (r4)-- (r5);
\path (r5)--node[right]{abce} (r6);
\path (r6)-- (r8);
\path (r8)-- (r9);
\path (r9)-- (r10);
\path (r5)-| node[near end]{bded} (r32);
\path (r7)->(r7-|r6); %<---- New line
\end{scope}
% the labels on the left
\node[cloud, above left=0mm and 7mm of r21.south west] (ab) {a\\b};
\node[cloud] at (ab|-r4) (abdd) {a\\b\\d\\d};
\node[cloud] at (ab|-r7) (aefgh) {a\\e\\f\\g\\h};
\node[cloud] at (ab|-r10) (abcd) {a\\b\\c\\d};
%red line
\draw[thick, red] ([shift={(3mm,-2mm)}]ab.south east)--+(180:13mm);
\draw[thick, red] ([shift={(3mm,2mm)}]aefgh.north east)--+(180:13mm);
\draw[thick, red] ([shift={(3mm,2mm)}]abcd.north east)--+(180:13mm);
\end{tikzpicture}
\end{document}