答案1
您可以选择每个孩子各自的形状。
不过,你还可以做很多事情,包括不需要硬编码。我对 Ti 了解不多钾Z 树/思维导图,但有一个教程在 Ti钾Z 文档,例子在 TeXample 上,有很多可以画树的包(例如forest
或者tikz-qtree
等),以及树木此网站上的标签。
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[%
level 1/.style={sibling distance=5cm},
level 2/.style={sibling distance=3cm},
every node/.style = {draw, minimum width=1.5cm, minimum height=.75cm, anchor=north},
edge from parent path={(\tikzparentnode.south) -- (\tikzchildnode.north)}]
]
\node[shape=ellipse, minimum height=1.25cm, minimum width=2cm] {R}
child { node[shape=rectangle, rounded corners] {A}
child { node[shape=rectangle] {A}
child { node[shape=ellipse] {B} }
child { node[shape=ellipse] {B} }
}
child { node[shape=ellipse] {B} }
}
child { node[shape=rectangle, rounded corners] {A}
child { node[shape=ellipse] {B} }
child { node[shape=ellipse] {B} }
};
\end{tikzpicture}
\end{document}
使用tikzstyle
您定义的:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\tikzstyle{decision} = [rectangle, minimum height=18pt, minimum width=18pt, draw=blue, fill=none, ultra thick, inner sep=0pt]
\tikzstyle{chance} = [circle, minimum width=18pt, draw=blue, fill=none, ultra thick, inner sep=0pt]
\tikzstyle{line} = [draw=none]
\begin{document}
\begin{tikzpicture}[%
level 1/.style={sibling distance=5cm},
level 2/.style={sibling distance=3cm},
every node/.style = {draw},
edge from parent path={(\tikzparentnode.south) -- (\tikzchildnode.north)}]
]
\node[chance] {R}
child { node[decision] {A}
child { node[decision] {A}
child { node[chance] {B} }
child { node[chance] {B} }
}
child { node[chance] {B} }
}
child[decision] { node {A}
child { node[chance] {B} }
child { node[chance] {B} }
};
\end{tikzpicture}
\end{document}