我正在为我的论文创建一些流程图,但却无法让它们看起来正确。
- 插入钥匙
- 让我的箭‘隧道’
第二点是指从“程序中断?”到“获取数据”的箭头
这是我当前的 TiKZ 代码:
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
\begin{document}
\pagestyle{empty}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=2.5cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=yellow!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, very thick, color=black!50, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=2.5cm,
minimum height=2em]
\tikzstyle{data} = [trapezium, draw, fill=green!20,
text width=5em, text centered, node distance=2.5cm, minimum height=0.5em]
\tikzstyle{input} = [regular polygon,regular polygon sides=5, draw, fill=cyan!20, text width=5em, text centered, node distance=2.5cm, minimum height=0.25em]
\begin{tikzpicture}[scale=2, node distance = 2cm, auto]
% Place nodes
\node [cloud] (start) {start};
\node [input, below of=start, node distance=2.5cm] (input) {Input parameters};
\node [input, below of=input, node distance=4cm] (initiate) {Initiate};
\node [block, below of=initiate, node distance=3cm] (calc) {Calculate focal laws};
\node [block, right of=calc, node distance=3cm] (acq) {Acquire data};
\node [data, below of=acq] (FMC) {FMC};
\node [data, below of=FMC] (process) {Process data};
\node [data, left of=process, node distance=3cm] (focal) {Focal laws};
\node [data, below of=process] (render) {Render image};
\node [decision, below of=render] (decide) {Interupt prgoramme?};
\node [cloud, below of=decide] (end) {end};
% Draw edges
\path [line] (start) -- (input);
\path [line] (input) -- (initiate);
\path [line] (initiate) -- (calc);
\path [line] (calc) -- (focal);
\path [line] (initiate) -| (acq);
\path [line] (acq) -- (FMC);
\path [line] (FMC) -- (process);
\path [line] (process) -- (render);
\path [line] (render) -- (decide);
\path [line] (focal) -- (process);
\path [line] (decide) -- node [, color=black] {yes}(end);
\path [line] (decide) -| node [, color=black] {no}(focal);
\end{tikzpicture}
\end{document}
解决方案这个答案看起来与我想要的类似,但如何将它从坐标(例如(0,2))转换为我的节点?
答案1
以下是如何使用“隧道”连接的示例Mark Wibrow 的代码使用命名节点/坐标而不是绝对位置。我还更新了语法和库。
\documentclass[tikz,multi,border=10pt]{standalone}
\usetikzlibrary{shapes.geometric,arrows.meta,positioning,calc,intersections}
\begin{document}
\tikzset{%
decision/.style={diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=2.5cm, inner sep=0pt},
block/.style={rectangle, draw, fill=yellow!20, text width=5em, text centered, rounded corners, minimum height=4em},
line/.style={draw, very thick, color=black!50, -LaTeX},
my cloud/.style={draw, ellipse,fill=red!20, node distance=2.5cm, minimum height=2em},
data/.style={trapezium, draw, fill=green!20, text width=5em, text centered, node distance=2.5cm, minimum height=0.5em},
input/.style={regular polygon,regular polygon sides=5, draw, fill=cyan!20, text width=5em, text centered, node distance=2.5cm, minimum height=0.25em},
connect/.style args={(#1) to (#2) over (#3) to (#4) by #5}{% code from Mark Wibrow, ref: https://tex.stackexchange.com/a/111674/
insert path={
\pgfextra{
\pgfinterruptpath
\path [name path=a] (#1) -- (#2);
\path [name path=b] (#3) -- (#4);
\path [name intersections={of=a and b,by=inter}];
\endpgfinterruptpath
}
let \p1=($(#1)-(inter)$), \n1={veclen(\x1,\y1)}, \n2={atan2(\y1,\x1)}, \n3={abs(#5)}, \n4={#5>0 ?180:-180} in (#1) -- ($(#1)!\n1-\n3!(inter)$) arc (\n2:\n2+\n4:\n3) -- (#2)
}
},
}
\begin{tikzpicture}[scale=2, node distance = 2cm, auto]
% Place nodes
\node [my cloud] (start) {start};
\node [input, below=25mm of start] (input) {Input parameters};
\node [input, below=40mm of input] (initiate) {Initiate};
\node [block, below=30mm of initiate] (calc) {Calculate focal laws};
\node [block, right=30mm of calc] (acq) {Acquire data};
\node [data, below=of acq] (FMC) {FMC};
\node [data, below=of FMC] (process) {Process data};
\node [data] (focal) at (calc |- process) {Focal laws};
\node [data, below=of process] (render) {Render image};
\node [decision, below=of render] (decide) {Interrupt programme?};
\node [my cloud, below=of decide] (end) {end};
% Draw edges
\path [line] (start) -- (input);
\path [line] (input) -- (initiate);
\path [line] (initiate) -- (calc);
\path [line] (calc) -- (focal);
\path [line] (initiate) -| (acq);
\path [line] (acq) -- (FMC);
\path [line] (FMC) -- (process);
\path [line] (process) -- (render);
\path [line] (render) -- (decide);
\path [line] (decide) -- node [color=black] {yes}(end);
\path [line] (decide) -| node [color=black] {no}(focal);
\coordinate (join) at ($(calc)!1/2!(acq)$);
\path [line, connect=(focal) to (process) over (decide.west -| join) to (join) by -5pt];
\path [line] (decide.west -| join) |- (acq.west);
\end{tikzpicture}
\end{document}