如何在第一张图片中的点 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}