13

I want to connect two tikz nodes with a line which should not overlap the other nodes. It additionally should branch below the node and run into the top again. I also want to label the edge/line.

I wrote this code:

\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}

This leads into the following result (left), what I want is on the right (red color not intended, just for clarification)

Current status Should status

How can this be done using tikz?

2
  • 2
    Does the following work: Replace the line style with redline/.style={draw,ultra thick, red,->,>=latex} and replace the path with \draw[redline] (nthRun.south) |- ++(0,-.3) -| ($(nthRun.east) +(5mm,0)$) node[right]{Iteration}|- ($(nthRun.20) +(0,.3)$) -- (nthRun.20) ; ?
    – percusse
    Commented Jan 2, 2012 at 19:13
  • @percusse: Thanks for the solution, it works well for my given example, but if you add more text, so the nTh Run node gets higher, your code does not work.
    – theomega
    Commented Jan 2, 2012 at 20:02

1 Answer 1

13
\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

1
  • @@theomega it's possible to reduce the code but it's more readable like this. Commented Jan 2, 2012 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .