编辑

编辑

我有多条不同长度(节点数)的垂直链。我希望所有这些链最终汇聚成最后一个节点。

我怎能这样做?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,scopes}

\begin{document}
\begin{tikzpicture}
    [
        start chain=main going right,
        every node/.style={draw},
        every join/.style={->,red}
    ]
    \node [on chain] {One};
    \node [on chain] {Two};
    {[start branch=two going below]
        \node [on chain,join] {x};
        \node [on chain,join] {y};
    }
    \node [on chain] {Three};
    {[start branch=three going below]
        \node [on chain,join] {a};
    }
    \node [on chain] {Four};

    % join all four chains to this node (with lines/arrows)
    \node {The End};
\end{tikzpicture}
\end{document}

答案1

像这样吗?

延长链

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{chains,scopes,positioning}

\begin{document}
\begin{tikzpicture}
    [
        start chain=main going right,
        every node/.style={draw},
        every join/.style={->,red}
    ]
    \node [on chain] {One};
    \node [on chain] {Two};
    {[start branch=two going below]
        \node [on chain,join] {x};
        \node [on chain,join] {y};
    }
    \node [on chain] {Three};
    {[start branch=three going below]
        \node [on chain,join] {a};
    }
    \node [on chain] {Four};

    % join all four chains to this node (with lines/arrows)
    \node [on chain, join, below=of main-4 |- main/two-3] {The End};
    \foreach \i in {main-1,main/two-3,main/three-2}
      \draw [every join] (\i) |- (main-5);
\end{tikzpicture}
\end{document}

编辑

针对评论中的疑问,如果您希望最终节点位于底部中央,您可以用一个库来替代:

\usetikzlibrary{chains,scopes,calc}

并依靠calc而不是positioning放置节点:

    \node [on chain, join, below=of current bounding box.south] {The End};

我不建议在这张图片中使用“阳光”型箭头,但如果您真的希望线条与鹰一起飞翔,那么只需将其替换|---

    \foreach \i in {main-1,main/two-3,main/three-2}
      \draw [every join] (\i) -- (main-5);

鹰输出

也许这在实际文档中比在最小示例中效果更好。虽然您始终可以将节点向下移动,但这显然会涉及添加额外的空间,而这不会增加任何信息价值。因此,除非有特殊原因(例如,您的图表代表老鹰的飞行路径),否则这似乎是一种更简单但不太优雅的选择。

[而且,由于阳光是由光子组成的,我们都知道它们在量子层面上的行为实际上并不是这样的。但我假设你只关心宏观层面的阳光,所以想要鹰。]

相关内容