连接在节点周围运行的 Tikz 节点

连接在节点周围运行的 Tikz 节点

我想用一条线连接两个 tikz 节点,该线不应与其他节点重叠。它还应在节点下方分支并再次进入顶部。我还想标记边/线。

我写了这段代码:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}

\begin{document}
\tikzset{
>=stealth',
  punktchain/.style={
    rectangle, 
    rounded corners, 
    draw=black, very thick,
    text width=14em, 
    minimum height=3em, 
    text centered, 
    on chain},
  line/.style={draw, thick, <-},
  every join/.style={->, thick,shorten >=1pt},
}
\begin{tikzpicture}
  [node distance=.6cm,
  start chain=going below,]
     \node[punktchain, join] (intro) {Introduction};
     \node[punktchain, join] (initRun)      {InitialRun};
     \node[punktchain, join] (nthRun)      {nTh Run};
     \node[punktchain, join] (conc) {Conclusion};
  \path[line] (nthRun.north east) -- ++(1,0) |- node{Iteration} (nthRun.south east);
\end{tikzpicture}
\end{document}

这导致了以下结果(左),我想要的是右边(红色不是故意的,只是为了澄清)

Current status Should status

如何使用 tikz 来完成这个?

答案1

\begin{tikzpicture}
  [node distance=.6cm,
  start chain=going below,]
     \node[punktchain, join] (intro) {Introduction};
     \node[punktchain, join] (initRun)      {InitialRun};
     \node[punktchain, join] (nthRun)      {nTh Run};
     \node[punktchain, join] (conc) {Conclusion};
  \path (nthRun) -- (conc) coordinate[pos=.5] (dep) ;
  \path (nthRun.north) -- (nthRun.north east) coordinate[pos=.25] (stop) ;
  \draw [red,thick,->] (dep) -| ([xshift=1cm] nthRun.east) node[right]{Iteration} |- ([yshift=10pt]stop) -- (stop);
\end{tikzpicture}

enter image description here

相关内容