\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.multipart}
\begin{document}
\tikzset{every loop/.style={min distance=1mm,in=110,out=70,looseness=2}}
\begin{tikzpicture}[->, thick, remember picture]
\node (0) at (-2,1) {};
\node[draw, shape=rectangle split, rectangle split parts=2, inner sep=3ex] (A) at (0,0) {
\begin{tikzpicture}[->, thick]
\node[draw, shape=rectangle split, rectangle split parts=2, inner sep=1ex] (test) {Sound \nodepart{two} 0 \{ \}};
\end{tikzpicture}
\nodepart{two} 0 \{ \}}; %First Error
\node[draw, shape=rectangle split, rectangle split parts=2] (B) at (4,0) {Camera \nodepart{two} 5 \{no\_obj\}};
\path[every node/.style={font=\sffamily\small}]
(A) edge [loop above] node [above] {no\_obj} (A)
(A.one east) edge node [above] {obj} (B.one west)
(test.one east) edge node [below] {no\_obj, obj} (B.two west);
\end{tikzpicture}
\end{document}
我的问题是,如何才能使外部节点的第二个节点部分与Sound
或Camera
节点的第二个节点部分一样小?
我真的不知道为什么会发生这种情况,我希望你能帮助我。
答案1
我已经通过文本宽度解决了这个问题,但我认为这不是应该采用的方式,而且它很丑,我需要手动为每张图片设置它。这是我得到的结果,我希望看到更好的解决方案:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.multipart}
\begin{document}
\tikzset{every loop/.style={min distance=1mm,in=110,out=70,looseness=2}}
\begin{tikzpicture}[->, thick, remember picture]
\node (0) at (-2,1) {};
\node[draw, shape=rectangle split, rectangle split parts=2, text width=5cm,
text height = 3.5cm, text centered] (A) at (0,0) {
\begin{tikzpicture}[->, thick]
\node[draw, shape=rectangle split, rectangle split parts=2, text width=2cm, text height = 0.3cm, text centered] (test) {Sound \nodepart{two} 0 \{ \}};
\node[draw, shape=rectangle split, rectangle split parts=2, text width=2cm, text height = 0.3cm, text centered] (Atest) at (0,2) {Test \nodepart{two} 0 \{ \}};
\end{tikzpicture}
\nodepart{two} 0 \{ \}}; %First Error
\node[draw, shape=rectangle split, rectangle split parts=2] (B) at (4,0) {Camera \nodepart{two} 5 \{no\_obj\}};
\path[every node/.style={font=\sffamily\small}]
(A) edge [loop above] node [above] {no\_obj} (A)
(A.one east) edge node [above] {obj} (B.one west)
(test.one east) edge node [below] {no\_obj, obj} (B.two west);
\end{tikzpicture}
\end{document}