I am working on a tree using tikz. Is there a way to define the node size globally? If I delete the text in my tree nodes they become really small. I want to define a different size for blue, orange and red nodes. And is there a way for automatic node alignment?
\documentclass{article}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}
%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\usetikzlibrary{positioning,shadows,arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[
fact/.style={circle, draw=none, rounded corners=1mm, fill=gray, drop shadow,
text centered, anchor=north, text=white},
state/.style={circle, draw=none, fill=orange, circular drop shadow,
text centered, anchor=north, text=white},
empty/.style={circle, draw=none, fill=blue, circular drop shadow,
text centered, anchor=north, text=white},
leaf/.style={circle, draw=none, fill=red, circular drop shadow,
text centered, anchor=north, text=white},
level distance=0.5cm, growth parent anchor=south
]
\node (Fact00) [fact] {$root$}
[sibling distance=5cm]
child{ [sibling distance=1.2cm]
node (State00) [state] {$pp$}
child{
node (State09) [empty] {$$}
}
child{
node (State09) [leaf] {$leaf$}
}
child{
node (State09) [empty] {$$}
}
child{ [sibling distance=3cm]
node (State09) [state] {$pp$}
child{ [sibling distance=1cm]
node (State10) [state] {$pp$}
child{
node (Leaf1) [leaf] {$leaf$}
}
child{
node (Leaf1) [leaf] {$leaf$}
}
}
child{ [sibling distance=1cm]
node (State10) [state] {$pp$}
child{
node (Leaf1) [leaf] {$leaf$}
}
child{
node (Leaf1) [leaf] {$leaf$}
}
}
}
}
child{ [sibling distance=1.2cm]
node (State00) [state] {$pp$}
child{
node (State09) [leaf] {$leaf$}
}
child{
node (State09) [leaf] {$leaf$}
}
}
child{ [sibling distance=1.2cm]
node (State00) [state] {$pp$}
child{
node (State09) [leaf] {$leaf$}
}
child{
node (State09) [leaf] {$leaf$}
}
child{
node (State09) [leaf] {$leaf$}
}
}
child{ [sibling distance=1.2cm]
node (State01) [state] {$pp$}
child{
node (State11) [leaf] {$leaf$}
}
child{
node (State09) [leaf] {$leaf$}
}
}
;
\end{tikzpicture}
\end{center}
\end{document}
minimum size
to your styles or for all nodes, as applicable. Automatic alignment etc.: either Forest or you can use the algorithmic layouts in the TikZ graph drawing libraries, which requires LuaTeX for the computations.minimal
for examples as it is not suitable.