答案1
像这样吗?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit}
\tikzset{
object1/.pic={
\node[circle,draw] (-A) {A};
\node[circle,draw, right=of -A] (-B) {B};
\node[circle,draw, above right=5mm and 1cm of -A] (-C) {C};
\draw[->] (-A)--(-C);
\draw[->] (-C)--(-B);
\node[draw, rounded corners, fit=(-A) (-B) (-C), label={[anchor=north west]north west:Object 1}]{};
}
}
\begin{document}
\begin{tikzpicture}[remember picture]
\path pic (Obj1) {object1};
\end{tikzpicture}
\hspace{2cm}
\begin{tikzpicture}[remember picture]
\path[blue] pic (Obj2) {object1};
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
\draw[red,->] (Obj1-B)--(Obj2-A);
\end{tikzpicture}
\end{document}
或这个?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning, fit}
\tikzset{
pics/object/.style 2 args={
code={
\begin{scope}[rotate=#2, transform shape]
\node[circle,draw] (-A) {A};
\node[circle,draw, right=of -A] (-B) {B};
\node[circle,draw, above right=5mm and 1cm of -A] (-C) {C};
\draw[->] (-A)--(-C);
\draw[->] (-C)--(-B);
\end{scope}
\node[draw, rounded corners, fit=(-A) (-B) (-C), label={[anchor=north west]north west:Object #1}, inner sep=5mm]{};
}
}
}
\begin{document}
\begin{tikzpicture}[remember picture]
\path pic (Obj1) {object={1}{0}};
\end{tikzpicture}
\hspace{2cm}
\begin{tikzpicture}[remember picture]
\path[blue] pic (Obj2) {object={2}{30}};
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
\draw[red,->] (Obj1-B)--(Obj2-A);
\end{tikzpicture}
\end{document}