![要列表的树节点文本](https://linux22.com/image/339257/%E8%A6%81%E5%88%97%E8%A1%A8%E7%9A%84%E6%A0%91%E8%8A%82%E7%82%B9%E6%96%87%E6%9C%AC.png)
我怎样才能将节点文本更改为列表?
例如,我想要以下内容:
\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[level distance=1.5cm,
level 1/.style={sibling distance=3.5cm},
level 2/.style={sibling distance=1cm}]
\node (Root) {3}
child {
node {1}
child { node {\begin{enumerate} \item Nested item 1 \item Nested item 2 \end{enumerate}} }
child { node {1} }
child { node {3} }
}
child {
node {2}
child { node {3} }
child { node {2} }
child { node {5} }
};
\end{tikzpicture}
\end{document}
但是我得到了 LaTeX 错误:
Something's wrong--perhaps a missing \item.
答案1
您需要将节点的内容放入某种盒子中。例如,您可以使用minipage
或\parbox
或任何类似的设备。
\documentclass[border=10pt,multi,tikz]{standalone}
\begin{document}
\begin{tikzpicture}[level distance=1.5cm,
level 1/.style={sibling distance=3.5cm},
level 2/.style={sibling distance=1cm}]
\node (Root) {3}
child {
node {1}
child { node {\begin{minipage}{45mm}\begin{enumerate} \item Nested item 1 \item Nested item 2 \end{enumerate}\end{minipage}} }
child { node {1} }
child { node {3} }
}
child {
node {2}
child { node {3} }
child { node {2} }
child { node {5} }
};
\end{tikzpicture}
\end{document}