在 Beamer 中使用 Overlay 指令時如何保留空間?

在 Beamer 中使用 Overlay 指令時如何保留空間?

在 Beamer 中,當我借助 Overlay 命令將數學公式中的一個表達式替換為另一個表達式時,我想保留空間。例如,如果我們在第 1 張投影片中有以下公式:

\[
x+\mathrm{Trace}M=y.
\]

我想用“z”替換“\mathrm{Trace}M”,這樣在幻燈片 2 中,之前的間距仍然相同,我們有:

\[
x+      z        =y.
\]

答案1

一種選擇:

\documentclass{beamer}
\usepackage{amssymb}

\newlength\mylen
\newlength\mylena
\newlength\mylenb

\newcommand\R{\mathbb{R}}
\newcommand\bL{bL}
\newcommand\Div{Div}

\newcommand\getmaxlength[2]{%
  \settowidth\mylen{#1}%
  \settowidth\mylena{#1}%
  \settowidth\mylenb{#2}%
  \ifdim\mylenb>\mylena\relax
    \setlength\mylen{\mylenb}
  \fi%  
 }
\newcommand\Replace[2]{%
  \getmaxlength{#1}{#2}%
  \makebox[\mylen][c]{#2}%
}

\begin{document}

\begin{frame}
\onslide<1,2>{
\[
x+
\only<1>{\mathrm{Trace}M}
\only<2>{\Replace{$\mathrm{Trace}M$}{$y$}}
=z
\]
}

\onslide<3,4>{
\[
x+
\only<3>{\Replace{$\mathrm{Trace}M$}{$y$}}
\only<4>{\Replace{$y$}{$\mathrm{Trace}M$}}
=z
\]
}

\onslide<5->{
Comme l'application d\'eterminant est diff\'erentiable et que sa diff\'erentielle en l'identit\'e est l'application trace, alors $p.p.\, y\in\R^3,\,$: 
\[
\only<5>{\mathrm{det}(D_y\Phi(t,y))}
\only<6->{\Replace{$\mathrm{det}(D_y\Phi(t,y))$}{$|J(t,y)|$}}=1+t\,\only<5>{\mathrm{Trace}(D_yV(y))}
\only<6->{\Replace{$\mathrm{Trace}(D_yV(y))$}{$\Div_y V(y)$}}
+t\,\epsilon_1(t,y),\,\epsilon_1(t)\xrightarrow{\bL^{\infty}}0.
\]
}
\end{frame}

\end{document}

在此輸入影像描述

主要命令是

\Replace{<text1>}{<text2>},

進行排版但保留 所使用的空間。對於數學模式下的表達式,參數應括在 中$...$

與問題無關,但請不要$$...$$在LaTeX文件中使用;代替使用\[...\];看為什麼 \[ ... \] 優於 $$ ... $$?

相關內容