为什么这个箭头渲染后会回到前面?

为什么这个箭头渲染后会回到前面?

梅威瑟:

% !TEX program = xelatex

\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}

\begin{document}

    \begin{tikzpicture}%
        \node (first)    {First};
        \node (second)   [below right=1cm of first] {Second};

        \begin{pgfonlayer}{bg}%
            \draw [->,rounded corners] (first.east) -| ($ (first.east-|second.north) + (0,-5mm) $) |- (second.north);
            \draw [->,rounded corners] (second.west) -| ($ (second.west-|first.south) + (0,5mm) $) |- (first.south);
        \end{pgfonlayer}
    \end{tikzpicture}%

\end{document}

结果:

在此处输入图片描述

second从到 的箭头first被渲染成从后向前,我不知道为什么。有人能告诉我吗?

注意:如果我禁用该线的圆角,那么它会正确呈现箭头:

在此处输入图片描述

更新:我可以让它渲染几乎通过翻转箭头正确:

\draw [-<,rounded corners] (second.west) -| ($ (second.west-|first.south) + (0,5mm) $)  |- (first.south);

显示内容:

在此处输入图片描述

但是,现在箭头离节点的文本太近了。

答案1

与您使用路径规范有关|-,将最后一个替换|---,它就可以正常工作。即而不是

\draw [->,rounded corners] (second.west) -| ($ (second.west-|first.south) + (0,5mm) $) |- (first.south);

使用

\draw [->,rounded corners] (second.west) -| ($ (second.west-|first.south) + (0,5mm) $) -- (first.south);

但是中间坐标到底有什么意义呢,为什么不这样做呢?

\draw [->,rounded corners] (first) -| (second);
\draw [->,rounded corners] (second) -| (first);

在此处输入图片描述

\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}

\begin{document}

    \begin{tikzpicture}%
        \node (first)    {First};
        \node (second)   [below right=1cm of first] {Second};

        \begin{pgfonlayer}{bg}%
            %\draw [->,rounded corners] (first.east) -| ($ (first.east-|second.north) + (0,-5mm) $) |- (second.north);
            %\draw [->,rounded corners] (second.west) -| ($ (second.west-|first.south) + (0,5mm) $) -- (first.south);

            \draw [->,rounded corners] (first) -| (second);
            \draw [->,rounded corners] (second) -| (first);
        \end{pgfonlayer}
    \end{tikzpicture}%

\end{document}

相关内容