beamer add tag
user 3.14159
**Disclaimer**: I am not a big fan of asking questions which I intend to answer myself, but here I'd like to make an exception because if I had known the answer earlier it would have helped me avoid a lot of hassle. I feel that many others who also have to prepare slides for courses that have to be remote because of the pandemic may find the information useful.

The question is if one can use the `beamer` command `\pause` in `amsmath` environments like `align`. The original question can be found at https://tex.stackexchange.com/q/549808. The official answer can be found in the `beamer` manual on p. 24:


> Euclid finds that he can also add a `\pause` between the definition and the example. So, `\pause`s seem to transcend environments, which Euclid finds quite useful. After some experimentation he finds that \pause only does not work in align environments. He immediately writes an email about this to beamer’s author, but receives a polite answer stating that the implementation of align does wicked things and there is no fix for this. Also, Euclid is pointed to the last part of the user’s guide, where a workaround is described.

The question is whether this is true, i.e. whether there is no way to have a variant of `\pause` that works in `align`. 
Top Answer
user 3.14159
It turns out that it *is* possible to define a variant of `\pause` that works in `align` (and so on) environments. The key point is taken from https://tex.stackexchange.com/a/442180, where it has been shown how one can "tame" `align` by only doing stuff when it is not measuring. That is, `align` "executes" its contents twice, and in the first run `\ifmeasuring@` is true but we want to inject `\pause` only in the second run, when it is not true. The analogous statements seem to apply
to `gather`, `aligned` and `gathered` but the `amsmath` source code isn't easy to read so I am not sure if this is the precise list. One can thus define one's own variant of `\pause`, which can be used in `align` environments. This variant can be used outside in the usual way since there the `\ifmeasuring@` conditional is false.

```
\documentclass{beamer}

% superior (?) pause command
\makeatletter
\newcommand{\Pause}[1][]{\unless\ifmeasuring@\relax
\pause[#1]%
\fi}
\makeatother

\begin{document}
\begin{frame}[t]
\frametitle{Equations revealed step by step}
Let us compute $(a+b)^2$.\Pause
\begin{align*}
(a+b)^2&=(a+b)(a+b)\\ \Pause
&=(a)(a)+(a)(b)+(b)(a)+(b)(b)\\ \Pause
&=a^2+ab+ba+b^2\\ \Pause
&=a^2+2ab+b^2
\end{align*}\Pause
In the last step we have assumed that $a$ and $b$ commute.
\end{frame}
\end{document}
```

Since `amsmath` gets loaded by beamer anyway, one could just redefine the `\pause` command to only get "activated" when not measuring.

```
\documentclass{beamer}
\makeatletter
\renewrobustcmd{\beamer@@pause}[1][]{%
  \unless\ifmeasuring@%
  \ifblank{#1}%
    {\stepcounter{beamerpauses}}%
    {\setcounter{beamerpauses}{#1}}%
  \onslide<\value{beamerpauses}->\relax%
  \fi%
}
\makeatother
\begin{document}
\begin{frame}[t]
\frametitle{Equations revealed step by step}
Let us compute $(a+b)^2$.\pause
\begin{align*}
(a+b)^2&=(a+b)(a+b)\\ \pause
&=(a)(a)+(a)(b)+(b)(a)+(b)(b)\\ \pause
&=a^2+ab+ba+b^2\\ \pause
&=a^2+2ab+b^2
\end{align*}\pause
In the last step we have assumed that $a$ and $b$ commute.
\end{frame}
\end{document}
```


![ani.gif](/image?hash=cf4fdbc32a52c924cfcf83c9773f38ef774bf54a6dac1640794269cb56ca68d2)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.