幻灯片中的树,每个节点暂停一次

幻灯片中的树,每个节点暂停一次

我有一张带有一些文字的幻灯片,我想在它们下面添加一棵树。

类似于下面的 gif。 在此处输入图片描述

每个节点的暂停实际上并不重要,但如果可能的话,效果会更好。是否有可能改变森林的大小?

我尝试了此代码但树超出了页面大小:

\documentclass{beamer}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\usepackage{lipsum}

\begin{document}
\begin{frame}[fragile]{Introduction}
    \begin{itemize}
        \setlength\itemsep{1em}
        \item \lipsum[1][1-5]
        \item \lipsum[1][1-5]
    \end{itemize}
    \begin{figure}
        \begin{forest}
            for tree = {
                circle, 
                draw, 
                edge = {-Straight Barb, semithick},
                l sep=8mm, 
                s sep=15mm, 
                minimum size = 3em,
                EL/.style 2 args = {edge label={%
                        node[midway, font=\footnotesize, align=center,
                        inner sep=2pt, anchor=south #1]{#2}},
                },
            }
            [Outlook,
            [Humidity, EL={east}{sunny}
            [Play, EL={east}{H $\leq$ 75}]
            [Don't play, EL={west}{H > 75}]
            ]
            [Play, EL={east}{Overcast}]
            [Wind, EL={west}{Raining}
            [Play, EL={east}{weak}]
            [Don't play, EL={west}{strong}]
            ]
            ]
        \end{forest}
    \end{figure}
\end{frame}
\end{document}

答案1

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{forest}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{overlay-beamer-styles}
\usepackage{lipsum}

\forestset{
  visible on/.style={
    for tree={
      /tikz/visible on={#1},
      edge+={/tikz/visible on={#1}}}}}

\begin{document}
\begin{frame}[fragile]
    \frametitle{Introduction}
    \begin{itemize}
        \setlength\itemsep{1em}
        \item \lipsum[1][1-5]
        \item \lipsum[1][1-5]
    \end{itemize}
    \begin{figure}
        \scriptsize
        \begin{forest}
            for tree = {
                ellipse, 
                draw, 
                edge = {-Straight Barb, semithick},
                l sep=1.5em, 
                s sep=2.5em, 
                minimum width=6em,
                EL/.style 2 args = {edge label={%
                        node[midway, font=\tiny, align=center,
                        inner sep=2pt, anchor=south #1]{#2}},
                },
            }
            [Outlook
            [Humidity, visible on=<2->, EL={east}{sunny}
            [Play, visible on=<3->, visible on=<3->, EL={east}{H $\leq$ 75}]
            [Don't play, visible on=<4->, EL={west}{H > 75}]
            ]
            [Play, visible on=<5->, EL={east}{Overcast}]
            [Wind, visible on=<6->, EL={west}{Raining}
            [Play, visible on=<7->, EL={east}{weak}]
            [Don't play, visible on=<8->, EL={west}{strong}]
            ]
            ]
        \end{forest}
    \end{figure}
\end{frame}
\end{document}

在此处输入图片描述

相关内容