2

Currently using forest to display Tableaux trees on beamer. For some cases i want a depth first step by step animation for the construction of the tree.

The idea is to start with the root visible, and then on each step nodes start to appear.

So im doing some tests with related solutions like this (Using beamer overlays with forest generated trees) proposed by @Qrrbrbirlbel wich i think is very clean:

\documentclass[xcolor={table, dvipsnames}]{beamer}
\usepackage{forest}

\setbeamertemplate{navigation symbols}{} %Remove navigation bar
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
    },
}
\forestset{
  closed/.style={      
   label=below:$\mathlarger{\mathlarger{\mathlarger{\times}}}$  
  },
  open/.style={      
   label=below:$\mathlarger{\mathlarger{\mathlarger{\odot}}}$
  },
  visible on/.style={
    for tree={
      /tikz/visible on={#1},
      edge+={/tikz/visible on={#1}}}}}
\begin{document}
\begin{frame}
\begin{forest}
  [A,for children={visible on=<2->}
    [B,for children={visible on=<3->}    % PROBLEM HERE, IT SHOULD BE ONLY FOR FIRST CHILD
      [C, for children={visible on=<4->}
        [D, open,for children={visible on=<5->}]
      ]
      [E,for children={visible on=<6->}
        [F, closed,for children={visible on=<7->}]
      ] 
    ]
  ]
\end{forest}
\end{frame}
\end{document}

The problem is that in the second step the "visible on" property is passed to both childrens C and E and they appear at the same time, but E should appear only after leaf D on the left branch. Im reading section 3.3.6 Propagators of the forest manual, mi (naive?) idea is to propagate only to first child, but i dont see any way to do this.

Another problem is that my tree styles open and closed created to put a label on special leafs on the tree should be hidden together with the node.

Any help to customize this would be appreciated.

0

Welcome to TeX-SE! I added visible on=<5->, to the E node and slightly changed the open and closed styles.

\documentclass[xcolor={table, dvipsnames}]{beamer}
\usepackage{forest}
\usepackage{relsize}
\setbeamertemplate{navigation symbols}{} %Remove navigation bar
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
    },
    %label visible on/.code={\tikzset{every label/.append style={visible on=#1}}}
}
\forestset{
  closed/.style={      
   label={[#1]below:$\mathlarger{\mathlarger{\mathlarger{\times}}}$ } 
  },
  open/.style={      
   label={[#1]below:$\mathlarger{\mathlarger{\mathlarger{\odot}}}$}
  },
  visible on/.style={
    for tree={
      /tikz/visible on={#1},
      edge+={/tikz/visible on={#1}}}}}
\begin{document}
\begin{frame}
\begin{forest}
  [A,for children={visible on=<2->}
    [B,for children={visible on=<3->}    % PROBLEM HERE, IT SHOULD BE ONLY FOR FIRST CHILD
      [C, for children={visible on=<4->}
        [D,open={visible on=<4->},for children={visible on=<5->}]
      ]
      [E,visible on=<5->,for children={visible on=<6->}
        [F,visible on=<6->, closed={visible on=<6->},for children={visible on=<7->}]
      ] 
    ]
  ]
\end{forest}
\end{frame}
\end{document}

enter image description here

  • Many thanks!. Im surprised i couldnt figure out the {visible on=<6->} thing. – fulem May 8 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.