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

처럼벤자민은 지적했다., 지수의 올바른 배치와 대괄호 내부의 일관된 간격은 다음을 사용하여 얻을 수 있습니다."Beamer alt 명령은 like only가 아닌 visible과 유사함"에 대한 Henry DeYoung의 답변:

\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, 밑받침이 숨겨져 있음(그러나 간격은 유지됨)

관련 정보