# Equation numbering problems in AMSMath environments with \pause

I'm writing a beamer presentation, and trying (unsuccessfully) to use \pause to step through a numbered array of equations, with the equations appearing in turn, and the corresponding numbers appearing at the correct time (i.e. when the equation first appears).

edit: I have partially solved the problem, using a variant on the \alt trick described here, but with some vertical wiggling.

The solution ought to be a little more elegant than the one I've proposed below, given that the end user of the document (not me) is likely to need to make changes, and is not an advanced (La)TeX-user.

\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{gather}
1\alt<2->{\\2\alt<3>{\\3}{}}{}
\end{gather}
\end{frame}
\end{document}

-

In the beamer user guide, in the explanation of \pause it says:

This command does not work inside amsmath environments like align, since these do really wicked things.

The wicked thing that align, gather and friends do is that they evaluate the contents of the environment twice. In particular, overlay commands such as \pause are executed twice, which can cause mayhem. In the first run, the contents of the environment are just measured; the actual typesetting is done in the second run.

Since the measuring in the first run starts with \begingroup \measuring@true, the problem can be fixed quite easily (although according to the beamer user guide "there is no fix for this"!): just let \measuring@true deactivate the appropriate overlay commands. (Of course one has to find out what exactly to deactivate ...) The code below does this, giving the desired output:

\documentclass{beamer}
\makeatletter
\let\save@measuring@true\measuring@true
\def\measuring@true{%
\save@measuring@true
\def\beamer@finalnospec{}%
}
\makeatother
\begin{document}
\begin{frame}
\begin{gather}
1 \\ \pause
2 \\ \pause
3
\end{gather}
\end{frame}
\end{document}

-
This is wonderful, thankyou! –  Nick Loughlin Feb 13 '13 at 16:36
@Nick: I should point out that I'm not sure about the line \def\beamer@sortzero##1{\beamer@ifnextcharospec{\beamer@sortzeroread{##1}}{}} anymore; this has unwanted side effects. Please try it first without that line! –  Hendrik Vogt Feb 13 '13 at 16:43

Possibly not the answer you're after, but it can be useful. The idea is to use \onslide instead of \pause; this, however, will produce still an undesired effect: the last equation number will appear on every slide, as can be seen in the following example:

\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{gather}
\onslide<1->{1\\}
\onslide<2->{2\\}
\onslide<3->{3}
\end{gather}
\end{frame}

\end{document}


A workaround is to add a new "fictitious" line at the end with no numbering (using \notag) and then to adjust the vertical space so that this new fictitious line doesn't add undesired vertical space, as the following example illustrates:

\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{gather}
\onslide<1->{1\\}
\onslide<2->{2\\}
\onslide<3->{3\\[-\baselineskip]\notag}
\end{gather}
\end{frame}

\end{document}

-