4

I am trying to change a formula between two slides. Here is an MWE

\documentclass{beamer}

\begin{document}

\begin{frame}{Title}
Something before\\
\bigskip
$%
B\left(%
\only<1>{A_2[i]}%
\only<2>{A_L[i]}%
\right) =%
\only<1>{C_1 + C_2}%
\visible<2>{\displaystyle\sum_{k=1}^{L} C_k}%
\quad \text{text here }%
\only<1>{a,b,c,}%
\only<2>{a,b,c,\ldots,z}
$

\end{frame}

\end{document}

As you can see, there is a problem with the position of "text here" in the first slide. If I put only instead of visible, that problem is solved but then everything moves during the transition. Is there a way to solve both issues?

1 Answer 1

6

The command \vphantom in useful in this case. It will reserve the vertical space required by the sum and thus prevent "wobbling" of the formula during overlays.

\documentclass{beamer}

\begin{document}

\begin{frame}{Title}
Something before\\
\bigskip
$%
B\left(%
\only<1>{A_2[i]}%
\only<2>{A_L[i]}%
\right) =%
\only<1>{C_1 + C_2 \vphantom{\displaystyle\sum_{k=1}^{L} C_k}}%
\only<2>{\displaystyle\sum_{k=1}^{L} C_k}%
\quad \text{text here }%
\only<1>{a,b,c,}%
\only<2>{a,b,c,\ldots,z}
$

\end{frame}

\end{document}
3
  • Yes, this is exactly what I wanted. So I learned a new command: vphantom: maybe one day I will know them all... Thank you!
    – minomic
    Sep 20, 2016 at 12:16
  • What about horizontal space? The text here a,b,c still moves left and right...
    – Alex
    Oct 28, 2017 at 13:30
  • 1
    @Alex For horizontal spacing you can do the same with \hphantom Nov 1, 2017 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .