修复森林动画

修复森林动画

我采用自下而上的方式创建树,解决方案如下:在 beamer 中从下到上呈现一棵{森林}树。但现在它似乎已经停止了作用。

当我执行以下操作时,会显示一些不应该存在的边缘:

在此处输入图片描述

我犯了错误吗?能以某种方式修复吗?

\documentclass[10pt]{beamer}

\usepackage[linguistics]{forest}


% http://tex.stackexchange.com/questions/167690/presenting-a-forest-tree-from-bottom-to-top-in-beamer
% showing and hiding nodes and edges in forest
\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{
  visible on/.style={
    for current and ancestors={
      /tikz/visible on={#1},
      edge={/tikz/visible on={#1}}}}}



\begin{document}

\frame{
\begin{forest}
[{V[subcat <> ]},visible on=<3->
  [1 NP
    [Aicke]]
  [{V[subcat < 1 >]},visible on=<2->
    [2 NP 
      [Conny]]
    [{V[subcat < 1, 2 >]}
      [erwartet]]]]
\end{forest}
}

\end{document}

答案1

这是解决方案:

\documentclass[10pt]{beamer}

\usepackage[linguistics]{forest}



\forestset{
  only/.code 2 args={\only<#1>{\pgfkeysalso{#2}}},
  temporal/.code n args=4{\temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}},
  alt/.code n args=3{\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}},
  onslide/.style={content format={\noexpand\onslide<#1>{$\forestoption{content}$}}},
}
\tikzset{
  only/.code 2 args={\only<#1>{\pgfkeysalso{#2}}},
  temporal/.code n args=4{\temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}}},
  alt/.code n args=3{\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}},
}
% patch beamer
\def\temporal<#1>#2#3#4{%beamer's \temporal is broken?
  % #1 --- must be a single frame number ...
  \alt<#1>{#3}{\alt<-#1>{#2}{#4}}%
}

% And here I adapt your "visible on" to include "edge-removal". 
\forestset{
 visible on/.style={
   alt={#1}{}{
     opacity=0,text opacity=0, for nodewalk={current, children}{edge'={}},
     % phantom % would do a similar job, but using it the tree "jumps"
   },
 },
} 


\begin{document}

\frame{
\begin{forest}
[{V[subcat <> ]},visible on=3-
  [1 NP
    [Aicke]]
  [{V[subcat < 1 >]},visible on=2-
    [2 NP 
      [Conny]]
    [{V[subcat < 1, 2 >]}
      [erwartet]]]]
\end{forest}
}

\end{document}

从 Sašo Živanović 处获得。谢谢。

最好的

斯蒂芬

相关内容