Beamer で下から上へ {forest} ツリーを表示する

Beamer で下から上へ {forest} ツリーを表示する

私はビーマーでツリーを紹介したいのですforestが、パーツごとに始まり、下から、そして頂上まで登ります。

そこで、次のような単純なツリーを考えてみましょう。

\documentclass{beamer}
\usepackage{forest}

\begin{document}

\begin{frame}
  \begin{forest}
    [VP, calign=last
      [{[ajout]}\\\textit{rapidement}, 
      align=center,
      base=top]
      [VP, calign=first
        [VP, calign=first
          [V\\\textit{mange}, align=center,base=top]
          [{[compl]}\\\textit{une orange}, align=center,base=top]
        ]
        [{[ajout]}\\\textit{dans la cuisine}, align=center,base=top]
      ]
    ]
  \end{forest}
\end{frame}

\end{document}

まずツリーの一番下 (つまり、基本的に「T」とその下の「mange」) を紹介したいと思います。次に上のブランチ (右側に子がいる VP)、さらにその上のレベル、というようにツリーの最上部まで紹介します (わかりやすく説明できていれば幸いです)。

に基づくこの議論、私は逆のやり方(上から下へ)を知っています。しかし、私が説明した通りにそれを実現するにはどうすればよいのでしょうか?

答え1

使用できますvisible onQrrbrbirlbel によって定義されたスタイルただし、それを使用する代わりにfor tree、それを実行しますfor ancestors'for ancestors'スタイルは実際のノードと親に適用されるため、visible on=<1->このノードと親、およびそれらの間のエッジはスライド 1 から表示されますが、親ノードに適用すると、visible on=<2->スライド 2 まで表示されません。

ノードと親の間のエッジも表示されますが、スタイル定義でスライド値を変更する方法がわかりません。祖先が表示されている場合にのみエッジを表示するための解決策は、手動でエッジの可視性を修正することです。

[{[ajout]}\\\textit{dans la cuisine}, align=center, visible on=<2->,edge={/tikz/visible on=<3->}]

完全なコードはこちら

\documentclass{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{
  visible on/.style={
    for ancestors'={
      /tikz/visible on={#1},
      edge={/tikz/visible on={#1}}}}}

\begin{document}
\begin{frame}[plain]{Same with forest}
  \begin{forest}
    [VP, calign=last, visible on=<4->
      [{[ajout]}\\\textit{rapidement}, 
      align=center,
      base=top, visible on=<3->, ]
      [VP, calign=first, visible on=<3->, 
        [VP, calign=first, visible on=<2->, 
          [V\\\textit{mange}, align=center,base=top, visible on=<1->, ]
          [{[compl]}\\\textit{une orange}, align=center,base=top, visible on=<1->, ]
        ]
        [{[ajout]}\\\textit{dans la cuisine}, align=center, visible on=<2->,]
      ]
    ]
  \end{forest}

\end{frame}
\end{document}

ここに画像の説明を入力してください

注記: なのでforest v2.0、キーfor ancestors'を に変更する必要がありますfor current and ancestors

答え2

これはバリエーションですイグナシの答えこれは、show up treeツリーを段階的に上向きに表示するスタイルを提供します。このスタイルは、単一のオーバーレイ仕様を渡すときに、エッジを子ではなく親と一緒に表示する方法も示しています。Ignasi は、2 つの異なるオーバーレイ仕様を渡すことによって処理することを提案しました。

\documentclass{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{
  show up tree/.style={
    before typesetting nodes={
      tempcounta/.max={level}{tree},
      tempcounta'+=1,
      for tree={
        /tikz/visible on/.process={ ROw2+nw {tempcounta}{level}{##1-##2}{<##1->} },
        edge+/.process={ ROw2+nw {tempcounta}{level}{(##1-##2)+1} {/tikz/visible on={ {<##1->} } }},
      }
    }
  }
}

\begin{document}
\begin{frame}[plain]{Same with forest}
  \begin{forest}
    show up tree
    [VP, calign=last, 
      [{[ajout]}\\\textit{rapidement}, 
      align=center,
      base=top,  ]
      [VP, calign=first,  
        [VP, calign=first,  
          [V\\\textit{mange}, align=center,base=top,  ]
          [{[compl]}\\\textit{une orange}, align=center,base=top,  ]
        ]
        [{[ajout]}\\\textit{dans la cuisine}, align=center, ]
      ]
    ]
  \end{forest}

\end{frame}
\end{document}

<code>ツリーを表示</code>

関連情報