我怎样才能将节点文本更改为列表?
例如,我想要以下内容:
\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}