2

I'm trying to animate a tree traversal. I want different nodes of the tree to be marked by a circle on different pages e.g. the first node of the topmost level and on the next slide the second node of the next level.

My minimal working example:

\documentclass[18pt,xcolor=table]{beamer}

\usepackage[linguistics]{forest}
\begin{document}
\begin{frame}{Access Operations - Basic Procedure}
\begin{figure}
\centering
\scalebox{0.8}{
\begin{forest}for tree={inner sep=0pt,outer sep=0pt, s sep=(3-level)*2mm, l=(125-level*level*level)*0.1mm}
  [,s sep=30
    [1, circle, draw
      [1, circle, draw
        [1]
        [1]
        [0]
        [0]
      ]
      [1
        [1]
        [0]
        [0]
        [0]
      ]
      [0]
      [1
        [0]
        [0]
        [0]  
        [1]
      ]
    ]
    [0]
    [1
      [0]
      [1
        [0]
        [1]
        [0]
        [1]
      ]
      [0]  
      [0]    
    ]
    [1
      [1
        [1]
        [1]
        [1]
        [0]
      ]
      [0]
      [0]
      [0]    
    ]
  ]
\end{forest}}
\end{figure}

\end{frame}
\end{document}

The resulting tree has both nodes marked: both nodes marked I want to mark one on the first slide and the other on the next slide. (I tried only and visible)

cfr
  • 198,882
Jan B
  • 229

1 Answers1

3

Here's a modification of part of the code I use which creates a draw on style. The code I use is inherited from a string of other answers, as explained in the comments below. I change whether the node is drawn, but not whether it is a circle, to avoid inconsistencies in sizing.

\documentclass[18pt,xcolor=table]{beamer}
\usepackage[linguistics]{forest}
\makeatletter
\tikzset{% set up for transitions using tikz with beamer overlays - developed by Daniel (http://tex.stackexchange.com/a/55849/) and, in earlier form, by Matthew Leingang (http://tex.stackexchange.com/a/6155/) and modified for this use, I think by Qrrbrbirlbel (http://tex.stackexchange.com/a/112471/)
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  },
  draw me/.style={draw},
  draw on/.style={alt=#1{draw me}{}},
}
\forestset{%
  draw on/.style={%
    /tikz/draw on={#1},
  }%
}
\makeatother

\begin{document}
\begin{frame}{Access Operations - Basic Procedure}
  \begin{figure}
    \centering
      \small % better than scaling the box
      \begin{forest}
        for tree={inner sep=0pt, outer sep=0pt, s sep=(3-level)*2mm, l=(125-level*level*level)*0.1mm}
        [,s sep=30
          [1, circle, draw on=<1>
            [1, circle, draw on=<2>
              [1]
              [1]
              [0]
              [0]
            ]
            [1
              [1]
              [0]
              [0]
              [0]
            ]
            [0]
            [1
              [0]
              [0]
              [0]
              [1]
            ]
          ]
          [0]
          [1
            [0]
            [1
              [0]
              [1]
              [0]
              [1]
            ]
            [0]
            [0]
          ]
          [1
            [1
              [1]
              [1]
              [1]
              [0]
            ]
            [0]
            [0]
            [0]
          ]
        ]
      \end{forest}
  \end{figure}
\end{frame}
\end{document}

circles on and off

cfr
  • 198,882
  • Please do NOT turn my slides into an animation :-). Thank you. – cfr Dec 13 '16 at 19:18
  • Why don't you like animations? They're the future! :D – Alenanno Dec 13 '16 at 19:20
  • @Alenanno GIFs are the future? Please, noooooooooooooo! – cfr Dec 13 '16 at 22:31
  • @Alenanno Besides, I don't like not being able to see what is going on all at the same time. If I miss the animation, it is over and gone. I want to see the steps. It is like wanting to see the code rather than the output. – cfr Dec 13 '16 at 22:32