# How to keep the horizontal overlay area space constant while the contents are updated?

I have the following problem with overlays in LaTeX beamer. On the first slide I want to display

while the second slide should show

The difficulty is to achieve that the amount of space occupied by 3+4+5 is also reserved on the first slide even though 12 would actually need less space.

The MWE below does NOT solve this problem. Is there any solution?

\documentclass{beamer}
\begin{document}
\frame{
\uncover<1-2>{}
1+2+\alt<1>{12}{3+4+5}+6+7=28
}
\end{document}

-
An easy fix would be \alt<1>{\phantom{3+}1\phantom{+5}}{3+4+5}, but it works if and only if the first alternative wouldn't have two digits. –  Claudio Fiandrino Mar 30 '13 at 10:43

\documentclass{beamer}

\newcommand\centerin[2]{{%
\ifmmode\def\dollar{$}\else\def\dollar{}\fi \settowidth{\dimen8}{\dollar#2\dollar}% \makebox[\dimen8]{\dollar#1\dollar}}} \def\altcenterin<#1>#2#3{\alt<#1>{\centerin{#2}{#3}}{#3}} \begin{document} \frame{ \uncover<1-2>{} 1+2+\altcenterin<1>{12}{3+4+5}+6+7=28 } \end{document}  - You can use features of beamer and of mathtools, combined with calc: \documentclass{beamer} \usepackage{mathtools,calc} \newcommand<>\mathalt[2]{% \alt#3{\mathmakebox[\widthof{$#2$}]{#1}}{#2}% } \begin{document} \begin{frame} \uncover<1-2>{}$1+2+\mathalt<1>{12}{3+4+5}+6+7=28\$

\end{frame}
\end{document}


First subframe:

Second subframe:

(The small difference is due just to the screen capture, sorry.)

-