答案1
这是使用包的示例forest
。它不是您可以实现的最佳匹配,但它有效。
\documentclass[border=3.14mm]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shapes.multipart,arrows.meta}
\forestset{rect/.style = {rectangle split,
rectangle split parts=2,
draw}
}
\begin{document}
\begin{forest}
for tree={edge={-Latex},child anchor=north,l=15mm}
[Methane,draw
[s1\nodepart{two}Carbon,rect]
[s2\nodepart{two}Hydrogen,rect]
[s3\nodepart{two}Hydrogen,rect]
[s4\nodepart{two}Hydrogen,rect]
[s5\nodepart{two}Hydrogen,rect]
]
\end{forest}
\end{document}
当然,你也可以用普通的 Ti钾Z,包括multiparts
选项,如下所示:
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.multipart,arrows.meta,positioning}
\tikzset{r/.style = {
rectangle split,
rectangle split parts=2,
draw,
inner sep=5pt,
align=center
}
}
\begin{document}
\begin{tikzpicture}[>=Latex]
\node[draw,minimum height=1cm](M){Methane};
\node[below=of M,r](3){s3\nodepart{two}\strut Hydrogen};
\node[left=of 3,r](2){s2\nodepart{two}\strut Hydrogen};
\node[left=of 2,r](1){s1\nodepart{two}\strut Carbon};
\node[right=of 3,r](4){s4\nodepart{two}\strut Hydrogen};
\node[right=of 4,r](5){s5\nodepart{two}\strut Hydrogen};
\foreach \i in {1,...,5}
\draw[->] (M) -- (\i.north);
\end{tikzpicture}
\end{document}