答案1
正如@Alan Munn 在他的评论中提到的,你的三个可以简单地使用positioning
和shapes.multipart
库绘制为纯 TikZ 图片:
\documentclass[tikz,margin=3.141592]{standalone}
\usetikzlibrary{arrows.meta,
positioning,
shapes.multipart}
\begin{document}
\begin{tikzpicture}[
node distance = 2mm and 11mm,
every edge/.style = {draw, -Straight Barb, very thick},
MPNV/.style = {
rectangle split,
rectangle split parts=10,
rectangle split ignore empty parts,
draw},
]
\node (n1) [MPNV=1] {single node};
\node (n2) [MPNV=3, right=of n1, anchor=three west]
{node 1 in group
\nodepart{two} node 2 in group
\nodepart{three} node 3 in group};
\node (n3) [MPNV=3, right=of n2] {node 1 in another group
\nodepart{two} node 2 in another group
\nodepart{three} node 3 in another group};
\node (n4) [MPNV=3, below=of n3] {node 1 in another group
\nodepart{two} node 2 in another group
\nodepart{three} node 3 in another group};
\node (n5) [MPNV=1, below right=of n2.east |- n4.south]
{another single node};
%
\path (n1.east) edge (n2.west)
(n2.one east) edge (n3.west)
(n2.two east) edge (n4.west)
(n2.three east) edge (n5.west);
\end{tikzpicture}
\end{document}
上面的 MWE 允许添加节点部分,最多可达十个。如果您想要更多的节点部分,则相应地增加rectangle split parts=...
。未使用的(空)节点不会被绘制。要绘制连接箭头,您需要使用nodepart
s 的锚点。