流程图路径规范

流程图路径规范

通缉

我想绘制如图所示的流程图。我生成的代码的问题在于指向顶部块和底部块的箭头(即)B&CD&E中心点相交,但我希望它们分别接触球体,如图所示。以下是我的代码:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{shapes,arrows,calc}

% Define block styles
\tikzstyle{block} = [rectangle, draw, fill=white, 
text width=5em, text centered, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=white, node distance=3cm,
minimum height=8em]

\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [cloud] (A) {AUTOMATIC TELLER MACHINE};


\node [block, left of=A,xshift=-4cm] (B) {B};
\node [block, below of=B,yshift=-2cm] (C) {C};
\node [block, above of=B,yshift=2cm] (D) {D};

\node [block, right of=A,xshift=4cm] (E) {E};
\node [block, below of=E,yshift=-2cm] (F) {F};
\node [block, above of=E,yshift=2cm] (G) {G};


%draw path 
\path [line] (A) -- node {}(B);
\path [line] (A) -- node {}(E);

\path [line] (A) |- (C);
\path [line] (A) |- (D);
\path [line] (A) |- (F);
\path [line] (A) |- (G);

\end{tikzpicture}
\end{document}

答案1

是這樣嗎?

在此处输入图片描述

这是通过

\path [line] (A.220) |- (C);
\path [line] (A.140) |- (D);
\path [line] (A.310) |- (F);
\path [line] (A.50) |- (G);

您的完整代码:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{shapes,arrows,calc}

% Define block styles
\tikzstyle{block} = [rectangle, draw, fill=white,
text width=5em, text centered, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=white, node distance=3cm,
minimum height=8em]

\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [cloud] (A) {AUTOMATIC TELLER MACHINE};


\node [block, left of=A,xshift=-4cm] (B) {B};
\node [block, below of=B,yshift=-2cm] (C) {C};
\node [block, above of=B,yshift=2cm] (D) {D};

\node [block, right of=A,xshift=4cm] (E) {E};
\node [block, below of=E,yshift=-2cm] (F) {F};
\node [block, above of=E,yshift=2cm] (G) {G};


%draw path
\path [line] (A) -- node {}(B);
\path [line] (A) -- node {}(E);

\path [line] (A.220) |- (C);
\path [line] (A.140) |- (D);
\path [line] (A.310) |- (F);
\path [line] (A.50) |- (G);

\end{tikzpicture}
\end{document}

答案2

PSTricks 解决方案:

\documentclass{article}

\usepackage{pstricks}

% parameter
\def\point{0.8 }

\begin{document}

\begin{pspicture}(-4,-2.5)(4,2.5)
  % ellipse
  \psellipse(0,0)(2,0.8)
  \rput(0,-0.1){\shortstack[c]{%
    \textsc{Automatic Teller}\strut\\[-0.75ex]
    \textsc{Machine}\strut}}
  \psset{arrows = ->}
  % left
  \psline(-2,0)(-3,0)
  \psframe(-4,-0.5)(-3,0.5)
  \psline(!-\point 0.4 4 \point dup mul sub sqrt mul)(-\point,2)(-3,2)
  \psframe(-4,1.5)(-3,2.5)
  \rput(-3.5,2){C}
  \rput(-3.5,0){F}
  \psline(!-\point -0.4 4 \point dup mul sub sqrt mul)(-\point,-2)(-3,-2)
  \psframe(-4,-2.5)(-3,-1.5)
  \rput(-3.5,-2){D}
  % right
  \psline(2,0)(3,0)
  \psframe(4,-0.5)(3,0.5)
  \psline(!\point 0.4 4 \point dup mul sub sqrt mul)(\point,2)(3,2)
  \psframe(4,1.5)(3,2.5)
  \rput(3.5,2){B}
  \rput(3.5,0){G}
  \psline(!\point -0.4 4 \point dup mul sub sqrt mul)(\point,-2)(3,-2)
  \psframe(4,-2.5)(3,-1.5)
  \rput(3.5,-2){E}
\end{pspicture}

\end{document}

输出

请注意,Automatic Teller Machine已向下移动 0.1 以使其更加美观。

此外,我发现 的值\point约为 0.8 可以产生最佳结果。

更新

这是一个完全“自动化”的版本,您所要做的就是选择参数的值,然后绘图将进行相应的调整:

\documentclass{article}

\usepackage{pstricks}
\usepackage{expl3}
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

%% pspicture boundry
\newcommand*\width{\calc{\major+2}}
\newcommand*\height{\calc{\minor+1.5}}

%% box with label
\def\boxLabel(#1,#2)#3{%
  \psframe(\calc{#1+0.5},\calc{#2+0.5})(\calc{#1-0.5},\calc{#2-0.5})
  \rput(\calc{#1},\calc{#2}){#3}}

%% constant
\def\const{\calc{\minor*sqrt(1-(\point/\major)^2)}}

%% parameters
\def\point{1}
\def\major{2}
\def\minor{0.8}

\begin{document}

\begin{pspicture}(-\width,-\height)(\width,\height)
\psset{arrows = ->}
  %% ellipse
  \psellipse(0,0)(\major,\minor)
  \rput(0,-0.1){\shortstack[c]{%
    \textsc{Automatic Teller}\strut\\[-0.75ex]
    \textsc{Machine}\strut}}
  %% left
  % top
  \psline(-\point,\const)%
         (-\point,\calc{\minor+1})%
         (-\calc{\major+1},\calc{\minor+1})
  \boxLabel(-\major-1.5,\minor+1){C}
  % middle
  \psline(-\major,0)(-\calc{\major+1},0)
  \boxLabel(-\major-1.5,0){F}
  % bottom
  \psline(-\point,-\const)%
         (-\point,-\calc{\minor+1})%
         (-\calc{\major+1},-\calc{\minor+1})
  \boxLabel(-\major-1.5,-\minor-1){D}
  %% right
  % top
  \psline(\point,\const)%
         (\point,\calc{\minor+1})%
         (\calc{\major+1},\calc{\minor+1})
  \boxLabel(\major+1.5,\minor+1){B}
  % middle
  \psline(\major,0)(\calc{\major+1},0)
  \boxLabel(\major+1.5,0){G}
  % bottom
  \psline(\point,-\const)%
         (\point,-\calc{\minor+1})%
         (\calc{\major+1},-\calc{\minor+1})
  \boxLabel(\major+1.5,-\minor-1){E}
\end{pspicture}

\end{document}

更新 2

这是另一个“自动化”版本,但代码较少:

\documentclass{article}

\usepackage{pstricks}
\usepackage{expl3}
\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

%% pspicture boundry
\newcommand*\width{\calc{\major+2}}
\newcommand*\height{\calc{\minor+1.5}}

%% box with label
\def\boxLabel(#1,#2)#3{%
  \psframe(\calc{#1+0.5},\calc{#2+0.5})(\calc{#1-0.5},\calc{#2-0.5})
  \rput(\calc{#1},\calc{#2}){#3}}

%% parameters
\def\point{1}
\def\major{2}
\def\minor{0.8}

\begin{document}

\begin{pspicture}(-\width,-\height)(\width,\height)
  %% left
  % connections
  \psline{<->}%
    (-\calc{\major+1},\calc{\minor+1})%
    (-\point,\calc{\minor+1})%
    (-\point,-\calc{\minor+1})%
    (-\calc{\major+1},-\calc{\minor+1})
  \psline{->}(-\major,0)(-\calc{\major+1},0)
  % boxes with label
  \boxLabel(-\major-1.5,\minor+1){C}
  \boxLabel(-\major-1.5,0){F}
  \boxLabel(-\major-1.5,-\minor-1){D}
  %% right
  % connections
  \psline{<->}%
    (\calc{\major+1},\calc{\minor+1})%
    (\point,\calc{\minor+1})%
    (\point,-\calc{\minor+1})%
    (\calc{\major+1},-\calc{\minor+1})
  \psline{->}(\major,0)(\calc{\major+1},0)
  % boxes with label
  \boxLabel(\major+1.5,\minor+1){B}
  \boxLabel(\major+1.5,0){G}
  \boxLabel(\major+1.5,-\minor-1){E}
  %% ellipse
  \psellipse[fillstyle = solid](0,0)(\major,\minor)
  \rput(0,-0.1){\shortstack[c]{%
    \textsc{Automatic Teller}\strut\\[-0.75ex]
    \textsc{Machine}\strut}}
\end{pspicture}

\end{document}

该解决方案的要点是,用白色填充的椭圆绘制在线的上方,这样它们就不需要恰好从椭圆的边界开始。

相关内容