# Problem with beamer's \pause in alignments

I have the following code, (edit:) now without aligned.

\documentclass{beamer}
\mode<presentation> { \setbeamercovered{transparent} }

\begin{document}
\begin{frame}
\begin{cases} %\begin{aligned} v(t,x) &= g(t,x), \\ \pause u(x) &= f(x) %& (x\in\mathbb R) %\end{aligned} \end{cases}
\end{frame}
\end{document}


(In the first version of the question, nothing was commented out.)

It compiles nicely, but everything except "u(x)" already shows up on the first slide if I use beamer.cls v 1.70 2007/03/11 18:50:44. On another computer at work we have an older version installed, namely v 1.55 2004/10/11 16:09:50; there everything works as expected: On the first slide, the full second line is shown in transparent style.

The same happens if I use plain TeX's \halign, so cases is not the culprit. Moreover, if I don't use \setbeamercovered{transparent}, then everything works as expected. In other words, \pause doesn't work together with \setbeamercovered{transparent} and \halign.

Is this a bug in beamer introduced between versions 1.55 and 1.70? (If yes, then I'm surprised since it'd regard it quite a serious one.) Does anyone know a workaround that doesn't involve as much markup as Matthew's answer to my original question?

-
This is true with v3.10, but I wonder if it might also be an AMS thing. Perhaps do \listfiles on both systems and report any other differences in addition to beamer. (Also, this might be best as a bug report for beamer.) –  Joseph Wright Dec 1 '10 at 18:05
@Joseph: Puh, reporting any other differences means a long list, but the only AMS differences are in amssymb and amsfonts. –  Hendrik Vogt Dec 1 '10 at 19:45
@Joseph: I finally found the "culprit": It's pdftex.def. On my old installation I have the version 2002/06/19 v0.03k, and with this it works as expected! I haven't yet the slightest clue why this is so. –  Hendrik Vogt Sep 13 '12 at 19:26
@Joseph: (I should have listened to you earlier!! By the way, even though align does wicked things, \pause works amazingly well inside align with my old pdftex.def. Do you know by any chance where I can find all the other old versions? So that I can look for the last "working" version?) –  Hendrik Vogt Sep 13 '12 at 20:02
I'd use the TeX Live SVN for this: tug.org/svn/texlive/trunk/Master –  Joseph Wright Sep 13 '12 at 20:06

From the beamer manual, in the middle of a use case:

Euclid finds that he can also add a \pause between the definition and the example. So, \pauses seem to transcede 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. (emphasis added)

Here is my workaround, using \action:

\documentclass{beamer}
\mode<presentation> { \setbeamercovered{transparent} }

\begin{document}
\begin{frame}
\begin{cases} \begin{aligned} \action<+->{v(t,x) &= g(t,x), \\} \action<+->{u(x)} &\action<.->{=f(x)} & \action<.->{(x\in\mathbb R)} \end{aligned} \end{cases}
\end{frame}
\end{document}


It's surprising that the second line has to have each cell of the align enclosed in an action specification while the first line can go in a single one (maybe that has something to do with the fact that it's shown by default on all slides). But I remember Till's advice to Euclid:

align does wicked things and there is no fix for this.

Added: \action is a generic \only if I recall correctly. And the incremental overlay specifications like <+-> are very much worth learning. See Section 8 of the beamer manual, or at least it's Section 8 of my 3.06 manual: "Creating Overlays."

-
Ah yes: now I remember reading this :-) –  Joseph Wright Dec 1 '10 at 19:16
Tsk, tsk: you forgot to indent all your code. More seriously, I must look up \action; I've no idea what that does. –  Loop Space Dec 1 '10 at 19:20
@Andrew: thanks for the friendly edit. –  Matthew Leingang Dec 1 '10 at 19:28
Thanks for telling me about \action. I'll try it tomorrow. However, I do know a fix for the wicked things: Use the old installation. Not quite satisfactory, obviously. –  Hendrik Vogt Dec 1 '10 at 19:47
Well, it works, thanks. But for the moment I'll stay with the old installation since it's too many \action s to type, and the code won't be as clear any more. Perhaps you know a less wicked replacement for aligned? –  Hendrik Vogt Dec 2 '10 at 13:15

(Posting this as a separate answer since I seriously propose the code here as a bug fix for beamer, or maybe even better for pgfsys-pdftex.def.)

In the end I found out the real cause of my trouble: beamerbasecolor.sty redefines the \reset@color command, and the redefinition contains the line

\pgfsys@color@unstacked{beamer@tempcolor}%


The pgf manual explains:

\pgfsys@color@unstacked{<LATEX color>}
This slightly obscure command causes the color stack to be tricked. When called, this command should set the current color to <LATEX color> without causing any change in the color stack.

The command \pgfsys@color@unstacked is defined in pgfsys.code.tex as

\def\pgfsys@color@unstacked#1{}


so usually it does nothing! However, if the dvips driver is used, then pgfsys-dvips.def is loaded, which contains the line

\def\pgfsys@color@unstacked#1{\special{ps: \XC@usecolor{#1}}}


There is no such line in pgfsys-pdftex.def, i.e., the command really does nothing if the document is compiled with pdflatex. (And this was quite alright with pdftex.def up to version 0.03t.)

Now the interesting thing is: if you compile the code from the question with latex -> dvips, then the output is just as one would expect! Thus, the solution is to also give a proper definition of \pgfsys@color@unstacked for the case that the pdftex driver is used. This definition should then go to pgfsys-pdftex.def. Here's a quick fix that defines the command in the preamble if needed:

\documentclass{beamer}
\mode<presentation> { \setbeamercovered{transparent} }
\makeatletter
\def\pdftex@driver{pdftex.def}
\ifx\Gin@driver\pdftex@driver
\def\pgfsys@color@unstacked#1{%
\pdfliteral{\csname\string\color@#1\endcsname}%
}
\fi
\makeatother
\begin{document}
\begin{frame}
\begin{cases} \begin{aligned} v(t,x)&= g(t,x), \\ \pause u(x) &= f(x) & \pause (x\in\mathbb R) \end{aligned} \end{cases}
\end{frame}
\end{document}

-
Please report to the pgf people: beamer just uses the code from this 'layer', and I am very reluctant to start patching other peoples stuff unless really necessary. –  Joseph Wright Sep 20 '12 at 13:51
@Joseph: I'll do that. (I'll just ping Christian Feuersänger here.) –  Hendrik Vogt Sep 20 '12 at 13:56
@Hendrik: Excellent analysis. I agree that it sounds like a good patch for the driver. But I honestly can't judge about the risk of that change... could you post it on the pgf mailing list? lists.sourceforge.net/lists/listinfo/pgf-users –  Christian Feuersänger Sep 20 '12 at 19:42
@Christian: Thanks! The risk should be 0: I did a grep in my root tex directory, and \pgfsys@color@unstacked is only ever used in beamerbasecolor.sty. About posting this on the pgf mailing list: Could you please do that for me? –  Hendrik Vogt Sep 20 '12 at 20:28
@Christian: Thanks a lot for posting the possible patch. –  Hendrik Vogt Sep 23 '12 at 8:40

Finally I followed Joseph's advice, and in the end found an easy fix for my problem: redefine \beamerorig@set@color and \beamerorig@reset@color to what they were before 2007. With the code below, the \pauses work exactly like expected:

I also tested this with two sets of real-world slides, and encountered no unwanted side effects.

\documentclass{beamer}
\mode<presentation> { \setbeamercovered{transparent} }
\makeatletter
\def\beamerorig@set@color{%
\pdfliteral{\current@color}%
\aftergroup\reset@color
}
\def\beamerorig@reset@color{\pdfliteral{\current@color}}
\makeatother
\begin{document}
\begin{frame}
\begin{cases} \begin{aligned} v(t,x)&= g(t,x), \\ \pause u(x) &= f(x) & \pause (x\in\mathbb R) \end{aligned} \end{cases}
\end{frame}
\end{document}


So it might well be that "align does wicked things" (see Matthew's answer), but before 2007, this was not relevant if \setbeamercovered{transparent} was used, so for me, \pause worked amazingly well within align. (A fix for the case that \setbeamercovered{transparent} is not used can be found in this answer of mine.)

And what happened in 2007? Version 0.04a of pdftex.def was released, with support of color stacks. For this, new definitions of \set@color and \reset@color were used; these are what \beamerorig@set@color and \beamerorig@reset@color are \let to in beamerbasecolor.sty. And it appears that this color stack version doesn't work properly in align and friends. In the code above, I used the definitions of \set@color and \reset@color form version 0.03t of pdftex.def.

-

If you don't mind using eqnarray in place of align, then you can get the pauses to work. At least that is my experience.

-
Welcome to TeX.sx! Feel free to visit our TeX.SX starter guide to get the most out of our site. –  Peter Jansson May 16 '13 at 21:50
Sorry to ask, but did you test your answer? I get the same problem with eqnarray. Moreover, note that I don't use align at all, only cases. –  Hendrik Vogt May 17 '13 at 6:09
Switching to eqnarray* worked for me. –  Amritanshu Prasad May 7 '14 at 7:59