线不在节点边缘的中心

线不在节点边缘的中心

我有一棵小树,我想在从节点 A 到节点 B 的边之间画一条线。

\begin{tikzpicture}[scale=0.8, level distance=1.5cm,
  every node/.style={draw, thick, rectangle, minimum width=2cm, minimum height=1cm, sibling distance=4cm, transform shape}]

\tikzset{edge from parent/.style={draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}}}

\Tree [ . \node (R){Crack password};
                            \node (A) {Acquire shadow file};
                            \node (B) {Acquire passwd file};
                        ]

\path (R) -- coordinate[left] (PA) (A);
\path (R) -- coordinate[right] (PB) (B);

\draw (PA) to[bend right=25] (PB);

\end{tikzpicture}

问题图片

如图所示,弯曲线向右偏移。我不知道为什么。

答案1

您可以指定north何时south绘制节点之间的路径。

输出

图1

代码

\documentclass[margin=10pt]{standalone}
\usepackage{tikz-qtree}

\usetikzlibrary{shapes,arrows,positioning}

\begin{document}
\begin{tikzpicture}[scale=0.8, level distance=1.5cm,
  every node/.style={draw, thick, rectangle, minimum width=2cm, minimum height=1cm, sibling distance=4cm, transform shape}]

\tikzset{edge from parent/.style={draw, edge from parent path={(\tikzparentnode) -- (\tikzchildnode)}}}

\Tree [ . \node (R){Crack password};
                            \node (A) {Acquire shadow file};
                            \node (B) {Acquire passwd file};
                        ]

\path (R.south) -- coordinate[left] (PA) (A.north);
\path (R.south) -- coordinate[right] (PB) (B.north);

\draw (PA) to[bend right=25] (PB);

\end{tikzpicture}
\end{document}

相关内容