如何在两个不同的 tikz 图片之间的点之间绘制边缘

如何在两个不同的 tikz 图片之间的点之间绘制边缘

如何在第一张图片中的点 a (=O) 和第二张图片中的点 d (=1) 之间画一条边:

\usepackage {tikz}
\usetikzlibrary {shapes,arrows,positioning}
\begin {tikzpicture} [-latex, node distance= 1cm]

\node [circle, draw] (a)  {0};

\node [circle, draw] (b) [right=of a] {1};

\node[above,font=\large\bfseries] at (current bounding box.north west) {M};

\end {tikzpicture}

\vspace {2cm}
\begin {tikzpicture} [-latex, node distance= 1cm] 

\node [circle, draw] (c)  {0};

\node [circle, draw] (d) [right=of c] {1};

\node [circle, draw] (e)[right=of d] {2};

\node[above,font=\large\bfseries] at (current bounding box.north west) {N};

\end {tikzpicture}

在此处输入图片描述 谢谢你!

答案1

您可以使用该remember picture选项访问其他 tikz 图片的坐标:

\documentclass{article}

\usepackage {tikz}
\usetikzlibrary {shapes,arrows,positioning}
\begin{document}
\begin {tikzpicture} [remember picture,-latex, node distance= 1cm]

\node [circle, draw] (a)  {0};

\node [circle, draw] (b) [right=of a] {1};

\node[above,font=\large\bfseries] at (current bounding box.north west) {M};

\end {tikzpicture}

\vspace {2cm}
\begin {tikzpicture} [-latex, node distance= 1cm,remember picture] 

\node [circle, draw] (c)  {0};

\node [circle, draw] (d) [right=of c] {1};

\node [circle, draw] (e)[right=of d] {2};

\node[above,font=\large\bfseries] at (current bounding box.north west) {N};

\draw[overlay] (a) -- (d);

\end {tikzpicture}
\end{document}

在此处输入图片描述

相关内容