This creates a new environment overlayauto which works like overlayarea but computes the height, width and depth from the data.
Note: this is like putting an \mbox in a math environment in that you need to use $...$ inside.
\documentclass{beamer}
\usepackage{environ}
% used to replace \only
\def\testonly<#1>#2{\setbox0=\hbox{#2}%
\ifdim\ht0>\maxheight\relax\maxheight=\ht0\fi
\ifdim\dp0>\maxdepth\relax\maxdepth=\dp0\fi
\ifdim\wd0>\maxwidth\relax\maxwidth=\wd0\fi
}
\NewEnviron{overlayauto}[1][\normalfont\raggedright]% #1 = minipage optons
{% get dimentsions from data
\dimendef\maxheight=0
\dimendef\maxwidth=1
\dimendef\maxdepth=2
\maxheight=0pt
\maxdepth=0pt
\maxwidth=0pt
\let\temp=\only
\let\only=\testonly
\BODY
\let\only=\temp
\raisebox{0pt}[\maxheight][\maxdepth]%
{\begin{minipage}[t]{\maxwidth}
#1\BODY
\end{minipage}}
}
\begin{document}
\begin{frame}
above
\begin{equation*}
a=\begin{overlayauto}
\only<1>{$b+c+d$}%
\only<2>{$\underbrace{b+c+d}_{\text{some text}}$}
\only<3>{$\overbrace{b+c+d}^{\text{some text}}$}
\end{overlayauto}
\end{equation*}
below
\end{frame}
\end{document}
underbraceshould be put insidephantom? – MikeL Sep 28 '15 at 08:56