I don't find the manual's explanation completely clear either. But the point is that child
is a path operation and an option xx
placed at the following point
\node {root}
[xx]
child ...
applies to all the child
paths. Now some options to paths get inherited by nodes on those paths, others do not. For example a colour blue
in \draw[blue] (0,0) -- (1,0) node {x};
will apply both to the path and the node; whereas \draw[rectangle] (0,2) -- (1,2) node {x};
will not have any effect. Node styles can be passed via every node/.style
:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[blue] (0,2) -- (1,2) node {x};
\draw[rectangle,draw] (0,1) -- (1,1) node {x};
\draw[every node/.style={rectangle,draw}] (0,0) -- (1,0) node {x};
\end{tikzpicture}
\end{document}
Similarly in your example there is an every child node/.style
that can be used.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[->,
rect/.style={inner sep=2pt,minimum size=2mm,draw,rectangle},
brect/.style={inner sep=2pt,minimum size=2mm,draw,rectangle,blue},
alive/.style={fill=orange,draw}]
\node[rect] at (2.5,4) {}
[blue]
child {node[alive] {}
child {node {empty}
}
}
;
\node[rect] at (5.5,4) {}
[every child node/.style=rect]
child {node[alive] {}
child {node {empty}
}
}
;
\node[rect] at (8.5,4) {}
[brect]
child {node[alive] {}
child {node {empty}
}
}
;
\end{tikzpicture}
\end{document}
Notice how the brect
style that contains a shape plus the colour blue
, when applied to a path just passes on the colour.
every child node/.append style=rect
should help here.