箭头目标位于 node.east 稍上方

箭头目标位于 node.east 稍上方

我试图让箭头最终位于node.east标记的略上方/下方。我尝试使用,但出于某种原因,只有当和坐标都非空时,calc tikzlibrary移动箭头的目的地才有效。xy

我的目标是能够区分到达和离开节点的箭头(b)

这个 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}

输出:

我的代码的输出

任何更清洁的方法来实现类似的结果也是可以的!

答案1

像这样吗?

在此处输入图片描述

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

答案2

在此处输入图片描述

使用positioning库和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}

相关内容