如何使用 \pause 使投影仪演示中的每个级别按顺序出现?

如何使用 \pause 使投影仪演示中的每个级别按顺序出现?
\documentclass[tikz,border=10pt]{standalone}  
\usepackage{pgfplots}  
\usepackage{forest}  
\usetikzlibrary{shadows}  
\begin{document}  
\begin{forest}
  shade me/.style={%  
    bottom color=#1!25,  
    top color=#1!5,  
    draw=#1,  
    drop shadow,  
    font=\Huge,  
  },  
  my label/.style n args=2{%  
    edge label={node [midway, black, font=\sffamily\large, #1] {#2}}  
  },  
  where n children=0{%  
    shade me=green!95!gray,
  }{%  
    if level=0{%  
      shade me=green!95!gray,  
    }{%  
      shade me=green!95!gray, 
    }  
  },  
  for tree={%  
    delay={content/.wrap value={\strut #1}},  
    edge={red,->},  
    l sep+=45pt,  
    s sep+=60pt  
  }  
  [100000 individuals  
  [100 affected, my label={above, xshift=1cm}{}  
      [{95\% true positives}, my label={below, xshift=-1.7cm}{}  
    [,phantom] [{95 + 999 test positive, Total = 1094}, my label={above, sloped}{}, name=aux1]]]  
    [99900 unaffected, my label={above, sloped}{}  
      [{1\% false positives}, my label={below, xshift=1.5cm}{}, name=aux  
 % [{95 + 999 test positive Total = 1094}, my label={above, sloped}{}]
 ]]        ]  
    ]  
  ]  
  \draw[red, ->] (aux)--(aux1);
\end{forest}  
\end{document} 

答案1

请注意,在开始解决方案之前,我必须以各种方式修改您的 MWE,以使其可以回答问题。

  1. 当问题本质上与特定类别有关时,合适的 MWE 需要使用该类别。在这种情况下,第一个明显需要的改变是使用beamer。否则,尝试实施增量揭露是没有意义的。(也许你可以尝试一下 选项beamerstandalone但你的 MWE 没有使用这个选项。)

  2. 第二个显然需要修改的是,在你思考关于花式叠加规范,您需要修改树规范,因为它本身并不适合 Beamer 幻灯片。它只是巨大的

  3. 树的很多代码完全没用,可以直接从示例中删除。没有边标签就同样适合这个目的,甚至可能比空边标签更好。

完成后,这里是基于我使用的方法的解决方案,这在很大程度上要感谢各位作者,尤其是代码中提到的 Qrrbrbirlbel。

\begin{filecontents}{mytree.tex}
\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\begin{document}
\begin{forest}
    shade me/.style={%
      bottom color=#1!25,
      top color=#1!5,
      draw=#1,
    },
    where n children=0{%
      shade me=green!95!gray,
    }{%
      if level=0{%
        shade me=green!95!gray,
      }{%
        shade me=green!95!gray,
      }
    },
    for tree={%
      delay={content/.wrap value={\strut #1}},
      edge={red,->},
      l sep+=20pt,
      s sep+=20pt,
      from slide/.wrap pgfmath arg={#1}{int(level()+1)},
    },
    delay={%
      for tree={%
        visible on=<\forestoption{from slide}->,
        alt=<\forestoption{from slide}->{drop shadow}{},
      }
    }
    [100000 individuals
      [100 affected
        [{95\% true positives}
          [,phantom
          ]
          [{95 + 999 test positive, Total = 1094}, name=aux1
          ]
        ]
      ]
      [99900 unaffected
        [{1\% false positives}, tikz+={\scoped[visible on=<4>]{\draw [red, ->] () -- (aux1);}}
        ]
      ]
    ]
  \end{forest}
\end{document}
\end{filecontents}
\documentclass{beamer}
\usepackage{forest,standalone}
\usetikzlibrary{shadows}
\tikzset{% set up for transitions using tikz with beamer overlays - developed by Daniel (http://tex.stackexchange.com/a/55849/) and, in ear lier form, by Matthew Leingang (http://tex.stackexchange.com/a/6155/) and modified for this use, I think by Qrrbrbirlbel (http://tex.stacke xchange.com/a/112471/)
  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={% developed by Qrrbrbirlbel (http://tex.stackexchange.com/a/112471/)
    for tree={%
      /tikz/visible on={#1},
      edge={/tikz/visible on={#1}}}},
  % based on Qrrbrbirlbel's answer at http://tex.stackexchange.com/a/112895/
  declare toks={from slide}{1},
}
\begin{document}
\begin{frame}
  \centering
  \input{mytree}
\end{frame}
\end{document}

逐层渐进地揭示

相关内容