使用森林包制作树的遍历动画

使用森林包制作树的遍历动画

我正在尝试制作树遍历的动画。我希望在不同的页面上用圆圈标记树的不同节点,例如最顶层的第一个节点,在下一张幻灯片上标记下一层级的第二个节点。

我的最小工作示例:

\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}

生成的树的两个节点均已标记: 两个节点均已标记 我想在第一张幻灯片上标记一个,在下一张幻灯片上标记另​​一个。(我尝试过,仅可见)

答案1

这是我用来创建样式的代码的一部分的修改draw on。我使用的代码是从其他答案中继承而来的,如下面的评论中所述。我更改了节点是否被绘制,但没有更改它是否是圆形,以避免尺寸不一致。

\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}

圆圈开和关

相关内容