I'm trying to do a beamer animation of a parse of a simple binary branching tree. I'd like to either use different colored branches and node labels to code the different steps of the parser and/or animate the parse. I don't know how to use \pause in the middle of a tree. Is that possible?

If I try to just do separate frames for each stage of the tree, LaTeX automatically resizes everything, so one node takes up a huge space on slide one, but less on slide two when it's joined with its daughters ... so it looks weird. Not like a structure that's being built one step at a time.

Any suggestions would be much appreciated!

{\Tree [.1 [.2 a ] [.3 [.4 b ] [.5 c ] ] ]}

2 Answers 2


For a simple animation that, e.g. presents distinct levels of the tree one at a time, you can just use \only<> and successively larger trees. If you use the [t] alignment option on the frame, you don't get the spacing problem you refer to.

\tikzset{edge from parent/.style={draw,very thick}}
    \frametitle{A tree}
    \only<1>{\Tree [.A B C ]}
    \only<2>{\Tree [.A [.B D E ] [.C ]]}
    \only<3>{\Tree [.A [.B D E ] [.C F G ]]}
    \only<4>{\Tree [.A [.B \edge[red]; \node{D}; \edge[blue]; \node{E}; ] [.C [.F H I ] G ]]}


Colouring branches is fairly easy (I've given one example in the last version of the tree); using the same technique to animate everything isn't very easy, however.

\begin{frame}[t]{A tree}

\Tree [.1 [ .2 \pause a ] [.3 [.4 \pause b ] [.5 \pause c ] ] ]


You must log in to answer this question.