Beamer:替换覆盖层中显示的方程式

Beamer:替换覆盖层中显示的方程式

[如果这是重复的,我很抱歉。我搜索并找到了相关问题,但无法解决我的问题。]

我有一个显示的方程式,我想用覆盖中的另一个方程式替换它不影响周围的文字。如下所示,我尝试了六种不同的方法,但都不起作用。在下面的“uncover”、“uncover&overprint”和“overprint&onslide”解决方案中,周围的文本是固定的,这正是我想要的,但等式发生了变化。在其他解决方案中,周围的文本发生了变化。

我知道通过包进行绝对文本定位textpos是一种解决方案,但它很繁琐。我还认为通过包为较小的等式赋予一个假高度phantom也是可行的。

但是,我认为已经有了一个简单的解决方案,看到它uncoveroverprint能够修复周围文本的位置。

\documentclass[14pt,aspectratio=1609]{beamer}
\begin{document}
%----
\begin{frame}{only}
Fixed text
\only<1>{\[\int f(x)\]}%
\only<2>{\[g(x)\]}%
fixed text.
\end{frame}
%---
\begin{frame}{uncover}
Fixed text
\uncover<1>{\[\int f(x)\]}%
\uncover<2>{\[g(x)\]}%
fixed text.
\end{frame}
%---
\begin{frame}{uncover \& overprint}
Fixed text
\begin{overprint}
\uncover<1>{\[\int f(x)\]}%
\uncover<2>{\[g(x)\]}%
fixed text.
\end{overprint}
\end{frame}
%----
\begin{frame}{Overprint \& onslide}
Fixed text
\begin{overprint}
\onslide<1>{\[\int f(x)\]}%
\onslide<2>{\[g(x)\]}%
\end{overprint}
fixed text.
\end{frame}
%----
\begin{frame}{Overprint, only, \& onslide}
Fixed text
\begin{overprint}
\only<1>{\[\int f(x)\]}%
\onslide<2>{\[g(x)\]}%
\end{overprint}
fixed text.
\end{frame}
%----
\begin{frame}{alt}
Fixed text
\alt<2->%
{\[g(x)\]}%
{\[\int f(x)\]}%
fixed text.
\end{frame}
\end{document}

答案1

正确的组合是overprint\onslide。注意:\onslide命令的使用方式类似于\item命令(即没有争论)。

\documentclass[14pt,aspectratio=1609]{beamer}
\begin{document}
\begin{frame}{Overprint \& onslide}
Fixed text
\begin{overprint}
  \onslide<1>
  \[\int f(x)\]

  \onslide<2>
  \[g(x)\]  
\end{overprint}
fixed text.
\end{frame}
\end{frame}
\end{document}

在此处输入图片描述

答案2

对于这个例子来说,下面的内容可能过于复杂,但如果你经常这样做,你可能会发现下面的方法很有用,它定义了一个新命令(来自这里:https://tex.stackexchange.com/a/63559/12212) 为此目的,Alt(注意大写“A”):

\documentclass[14pt,aspectratio=1609]{beamer}

% https://tex.stackexchange.com/questions/13793/beamer-alt-command-like-visible-instead-of-like-only
\usepackage{etoolbox}
\makeatletter
\newcommand<>\Alt[2]{{%
    \sbox0{$\displaystyle #1$}%
    \sbox1{$\displaystyle #2$}%
    \alt#3%
        {\rlap{\usebox0}\vphantom{\usebox1}\hphantom{\ifnum\wd0>\wd1 \usebox0\else\usebox1\fi}}%
        {\rlap{\usebox1}\vphantom{\usebox0}\hphantom{\ifnum\wd0>\wd1 \usebox0\else\usebox1\fi}}%
}}
\makeatother

\begin{document}
\begin{frame}{only}
Fixed text\bigskip{}
\[\Alt<2->{g(x)}{\int f(x)}\]%
fixed text.
\end{frame}
\end{document}

在此处输入图片描述

相关内容