考虑这个例子:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[left] at (0,0) (Source) {Source};
\draw [very thick, ->] (0.15,-0.02) -- (2.5,0.48);
\node[right] at (2.5,0.5) (Target1) {abcdefgh};
\node at (Target1) (Target1arrow) {};
\draw [very thick, ->] (2.35,0.52) -- (0,0.02);
\node[right] at (2.5,-0.5) (Target2) {abcdefg};
\node at (Target2) (Target2arrow) {};
\draw [very thick, ->] (0.15,-0.02) -- (2.5,-0.5);
\draw [very thick, ->, shorten <= .5ex, shorten >= .5ex] (Target1arrow) -- (Target2arrow);
\end{tikzpicture}
\end{document}
我知道垂直箭头从 的中点开始Target1
并指向 的中点Target2
,但在这种情况下,这两个目标的长度几乎相同,如果箭头是直的,看起来会更好。换句话说,我希望箭头的起点固定在 的中心点Target2
。我尝试添加anchor = Target2.base
此箭头的绘制功能,但没有效果。
答案1
首先,可以选择将一个节点置于另一个节点下方(Pier Paolo 解释道)。
还有(node1 |- node2)
垂直绘制线条的语法。在这种情况下,箭头的末端写为(Target1arrow |- Target2arrow.north)
。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[left] at (0,0) (Source) {Source};
\draw [very thick, ->] (0.15,-0.02) -- (2.5,0.48);
\node[right] at (2.5,0.5) (Target1) {abcdefgh};
\node at (Target1) (Target1arrow) {};
\draw [very thick, ->] (2.35,0.52) -- (0,0.02);
\node[right] at (2.5,-0.5) (Target2) {abcdefg};
\node at (Target2) (Target2arrow) {};
\draw [very thick, ->] (0.15,-0.02) -- (2.5,-0.5);
\draw [very thick, ->, shorten <= .5ex, shorten >= .5ex] (Target1arrow) -- (Target1arrow |- Target2arrow.north);
\end{tikzpicture}
\end{document}