如何使用 onslide 正确显示指数?

如何使用 onslide 正确显示指数?

我需要在括号 [] 内使用 \onslide 和 \underbrace,并将其提升到指数。但是,当我使用 \onslide 时,指数无法正确显示。有办法解决这个问题吗?下面是使用和不使用 \onslide 的比较代码。

\documentclass[english]{beamer}
\begin{document}

\begin{frame}
\begin{align*}
\left[             \underbrace{A}_{Text} + B \right]^{C} % Works: Power C   correctly displayed
\\ \\
 \left[ \onslide<1> \underbrace{A}_{Text} + B \right]^{C} % Does not work: Power  C not correctly displayed
\end{align*}
\end{frame}

\end{document}

答案1

作为本杰明指出,可以使用以下方法实现指数的正确放置和括号内的一致间距Henry DeYoung 对“Beamer alt 命令类似于可见,而不是仅类似于”的回答

\documentclass[english]{beamer}

% Beamer alt command like visible instead of like only (answer by Henry DeYoung)
% (https://tex.stackexchange.com/a/63559)
\usepackage{etoolbox}
\usepackage{mathtools}

\makeatletter
% Detect mode. mathpalette is used to detect the used math style
\newcommand<>\Alt[3][l]{%
  \begingroup
    \providetoggle{Alt@before}%
    \alt#4{\toggletrue{Alt@before}}{\togglefalse{Alt@before}}%
    \ifbool{mmode}{%
      \expandafter\mathpalette
      \expandafter\math@Alt
    }{%
      \expandafter\make@Alt
    }%
    {{#1}{#2}{#3}}%
  \endgroup
}

% Un-brace the second argument (required because \mathpalette reads the three arguments as one
\newcommand\math@Alt[2]{\math@@Alt{#1}#2}

% Set the two arguments in boxes. The math style is given by #1. \m@th sets \mathsurround to 0.
\newcommand\math@@Alt[4]{%
  \setbox\z@ \hbox{$\m@th #1{#3}$}%
  \setbox\@ne\hbox{$\m@th #1{#4}$}%
  \@Alt{#2}%
}

% Un-brace the argument
\newcommand\make@Alt[1]{\make@@Alt#1}

% Set the two arguments into normal boxes
\newcommand\make@@Alt[3]{%
  \sbox\z@ {#2}%
  \sbox\@ne{#3}%
  \@Alt{#1}%
}

% Place one of the two boxes using \rlap and place a \phantom box with the maximum of the two boxes
\newcommand\@Alt[1]{%
  \setbox\tw@\null
  \ht\tw@\ifnum\ht\z@>\ht\@ne\ht\z@\else\ht\@ne\fi
  \dp\tw@\ifnum\dp\z@>\dp\@ne\dp\z@\else\dp\@ne\fi
  \wd\tw@\ifnum\wd\z@>\wd\@ne\dimexpr\wd\z@/2\relax\else\dimexpr\wd\@ne/2\relax\fi
  %
  \ifstrequal{#1}{l}{%
    \rlap{\iftoggle{Alt@before}{\usebox\z@}{\usebox\@ne}}%
    \copy\tw@
    \box\tw@
  }{%
    \ifstrequal{#1}{c}{%
      \copy\tw@
      \clap{\iftoggle{Alt@before}{\usebox\z@}{\usebox\@ne}}%
      \box\tw@
    }{%
      \ifstrequal{#1}{r}{%
        \copy\tw@
        \box\tw@
        \llap{\iftoggle{Alt@before}{\usebox\z@}{\usebox\@ne}}%
      }{%
      }%
    }%
  }%
}
\makeatother

\begin{document}

\begin{frame}<1-2>
\begin{align*}
    \left[ \Alt<1>[c]{\underbrace{\only<*>{A}}_{Text}}{A} + B \right]^{C}
\end{align*}
\end{frame}

\end{document}

幻灯片 1,显示下部支撑

幻灯片 2,隐藏底部支撑(但保留间距)

相关内容