范围或者覆盖 \pause?

范围或者覆盖 \pause?

我有一些包含多部分问题的讲座幻灯片。我希望学生能够看到整个问题的布局,然后逐步填写答案。只要填写的内容可以分成漂亮的小块,这就可以做到:

\documentclass{beamer}
\begin{document}

\begin{frame}\onslide<+->{}
This problem has three parts.
  \begin{enumerate}
    \item What is the answer to part 1?\\
      \onslide<+->{First interpret the question.}\onslide<+->{ Then do some work.}\onslide<+->{ Now we can answer the question, and the answer is} \onslide<+->{ 42.}
    \item What is the answer to part 2?\\
      \onslide<+->{This problem is easy, and the answer is }\onslide<+->{0.}
    \item What is the answer to part 3?\\
      \onslide<+->{You'll have to figure this one out for yourself.}
  \end{enumerate}
\end{frame}
\end{document}

这个解决方案相当优雅(除了初始\onslide<+->增加计数器)。不幸的是,如果我想在环境中间暂停,比如对齐,它就会崩溃(或至少变得非常混乱):

\documentclass{beamer}
\usepackage{amsmath}
\begin{document}
%% Standard (?) fix to make \pause work at all in align environment
\mode<presentation>{\setbeamercovered{transparent=0}}
\makeatletter
\def\beamerorig@set@color{%
  \pdfliteral{\current@color}%
  \aftergroup\reset@color
}
\def\beamerorig@reset@color{\pdfliteral{\current@color}}
\makeatother
%%

\begin{frame}
This problem has three parts.
  \begin{enumerate}
    \item What is the answer to part 1?\\\pause
      First interpret the question. Then calculate
      \begin{align*}
        \Pr[X\in A] &=\pause \frac{1}{2^n} \sum_{i=0}^n \binom{n}{i} \\ 
        &=\pause 1
      \end{align*}
    \item What is the answer to part 2?\\\pause
      More answers, \pause with more parts.
    \item What is the answer to part 3?\\\pause
      ...
  \end{enumerate}
\end{frame}
\end{document}

当然,如果我这样做,问题的后面部分直到我们完成第一部分之后才会出现。

我可能可以通过将答案分解成更小的块,然后确保之前的文本和第一部分align同时显示,使前一种方法奏效,但这似乎需要根据具体情况进行大量手动操作。我认为正确的解决方案是将效果限制在\pause答案本身的某个范围内,或者通过强制我希望在开头显示的后面材料不透明来覆盖它(我相信的修复align已经使文本始终存在,只是透明的)。

有什么好办法吗?

答案1

我最终使用了以下解决方法,使用(不可否认非常黑客的)\always命令来重置其内容的幻灯片计数器:

\documentclass{beamer}
\usepackage{amsmath}
%% Standard (?) fix to make \pause work at all in align environment
\mode<presentation>{\setbeamercovered{transparent=0}}
\makeatletter
\def\beamerorig@set@color{%
  \pdfliteral{\current@color}%
  \aftergroup\reset@color
}
\def\beamerorig@reset@color{\pdfliteral{\current@color}}
\makeatother
%%

%% \always{} command ensures that its contents are visible on all slides of the frame.
\newcounter{beamerpausessave}
\newcommand{\always}[1]{\setcounter{beamerpausessave}{\value{beamerpauses}}
    \setcounter{beamerpauses}{0}\pause #1 
    \setcounter{beamerpauses}{\value{beamerpausessave}}\addtocounter{beamerpauses}{-1}\pause}

\begin{document}
\begin{frame}
This problem has three parts.
  \begin{enumerate}
    \always{\item What is the answer to part 1?\\}\pause
      First interpret the question. Then calculate
      \begin{align*}
        \Pr[X\in A] &=\pause \frac{1}{2^n} \sum_{i=0}^n \binom{n}{i} \\ 
        &=\pause 1
      \end{align*}
    \always{\item What is the answer to part 2?\\}\pause
      More answers, \pause with more parts.
    \always{\item What is the answer to part 3?\\}\pause
      ...
  \end{enumerate}
\end{frame}

\end{document}

我还是不太明白为什么这种特殊的设置beamerpauses和使用组合\pause会起作用,而没有更简单的方法可以起作用。

相关内容