1

I'm trying to get an arrow to end up slightly above/below a node.east marker. I tried using the calc tikzlibrary but for some reason, shifting the arrow's destination only works if I both x and y coordinates are non null.

My goal is to be able to distinguish the arrows arriving at and leaving node (b).

What's wrong with this MWE?

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{chains, positioning, calc}
\usepackage{enumitem}
\usepackage{etoolbox}

\begin{document}
\begin{tikzpicture}[node distance = 2cm, start chain = going below]

  \node[on chain] (a) {a};
  \node[on chain] (b) {b};
  \node[on chain] (c) {c};

  \node[anchor=west] at ($(a)!0.5!(b) + (0:1) $) (d) {d};
  \node[anchor=west] at ($(b)!0.5!(c) + (0:1) $) (e) {e};

  \draw[->] (a.east) -| (d.north);
  \draw[->] (d.south) |- ($(b.east) - (0.5:0)$);
  \draw[->] ($(b.east) + (0.5:0)$) -| (e.north);
  \draw[->] (e.south) |- (c.east);

\end{tikzpicture}
\end{document}

The output:

My code's output

Any cleaner approach to achieve a similar result is OK too!

  • 1
    The polar coordinate system uses (angle:distance) (so (0.5:0) is at a null distance from the origin at 0.5 degree!). – Paul Gaborit Apr 6 '18 at 14:24
  • Dammit, I just had to use a comma instead of a double dot. Thanks! – nicoco Apr 6 '18 at 14:28
2

Something like this?

enter image description here

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{chains, positioning, calc}
\usepackage{enumitem}
\usepackage{etoolbox}

\begin{document}
\begin{tikzpicture}[node distance = 2cm, start chain = going below]

  \node[on chain] (a) {a};
  \node[on chain] (b) {b};
  \node[on chain] (c) {c};

  \node[anchor=west] at ($(a)!0.5!(b) + (1,0) $) (d) {d};
  \node[anchor=west] at ($(b)!0.5!(c) + (1,0) $) (e) {e};

  \draw[->] (a.east) -| (d.north);
  \draw[->] (d.south) |- ($(b.east)+(0,0.1)$);
  \draw[->] ($(b.east)-(0,0.1)$) -| (e.north);
  \draw[->] (e.south) |- (c.east);

\end{tikzpicture}
\end{document}
  • This looks good with the toy example, but with my real case, I don't want to reach north|south east because the nodes are way bigger and closer to one another. I really want to target "just above|below" of b.east. – nicoco Apr 6 '18 at 14:24
  • @nicoco Ooh... See if it is good for you now. – Phelype Oleinik Apr 6 '18 at 14:28
  • Yes it is, I was using polar coordinates without knowing it. Thanks! – nicoco Apr 6 '18 at 14:29
1

enter image description here

with use of the positioning library and a yshift:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
node distance = 1cm and 1cm
                        ]
  \node             (a) {a};
  \node[below right=of a] (d) {d};
  \node[below  left=of d] (b) {b};
  \node[below right=of b] (e) {e};
  \node[below  left=of e] (c) {c};

  \draw[->] (a) -| (d);
  \draw[->] (d) |- ([yshift=2] b.east);
  \draw[->] ([yshift=-2] b.east) -| (e);
  \draw[->] (e) |- (c);
    \end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.