I've tried reading the excellent Beamer user guide, but failed to understand.

I understand the basic idea: there's a counter beamerpauses that is advanced by a + inside an overlay specification. You can for example write \item<+> and you'll get an item that only shows for the slide with the current value of beamerpauses. Also, beamerpauses gets increased by one.

So far so nice.

One can write \item<.>. This has the effect of turning on the item for the previous (-1) value of beamerpauses, and it does not increase the counter.


Now what happens here (edited so that it does something interesting:)

\only<.(2)-+(6)>{\alert<+->{foo}\alert<+->{bar}} \only<-.(2)>\alert<-+>{BAR}\alert<-+(1)>{FOO}}
      (1)          (2)            (3)                (4)                         (5)

is it equivalent to



In particular: When does the increment at (1) happen? Before both the arguments are processed or after? Do the increments at (2) and (3) affect the counter when (4) and (5) are evaluated?

How does the counter change in this case? what is its value at every point? How can I find out? I tried writing \thebeamerpauses but this counter does not seem to change with the slides. Is there a counter that holds the slide number?

  • even \alt<-+>{foo}{bar} doesn't behave as expected. Is this a typo?
    – Seamus
    Dec 2, 2010 at 11:14
  • It's not clear what the code above is expected to do. Could you add the same example with explicit slide specifications, so we see what it is you expected...
    – Seamus
    Dec 2, 2010 at 11:17
  • I edited the code, making it a little more interesting...I think. Dec 2, 2010 at 14:39
  • I would like to close this question and open a new one which would be more focused....is that a reasonable thing to do? Dec 3, 2010 at 10:41

2 Answers 2


The rules for the incremental overlay specification are given as:

  1. \beamerpauses is initially set to 1
  2. If + is encountered in an overlay specification, all occurrences of + are replaced by \beamerpauses, then \beamerpauses is incremented
  3. If . is encountered in an overlay specification, all occurrences of . are replaced by \beamerpauses-1; \beamerpauses is not changed

It might be easier to understand if you pretend this, which as far as I can see is equivalent:

  1. \beamerpauses is initially set to 0
  2. If + is encountered in an overlay specification, \beamerpauses is incremented and all occurrences of + are replaced by \beamerpauses
  3. If . is encountered in an overlay specification, all occurrences of . are replaced by \beamerpauses; \beamerpauses is not changed

If you assume as well that \alt is smart and gobbles the inactive argument rather than expands it, you would guess that


is the same as


On slide 1, the first argument \alert<+>{foo}\alert<+>{bar} is expanded, resulting in


After slide 1, the second argument \alert<.>{bar}\alert<.>{foo} is instead expanded, resulting in


So in total the combination is equivalent to


Put these in the same frame and you'll see they do the same thing.

The - indicates an interval, so <2-4> means "on slides 2 through 4." Without explicit endpoints the first and last slide are substituted. So the first <-+> specification is equivalent to <1-1>, which in turn is equivalent to <1>.

Slide by slide we get:

  1. the \alt expands \alert<2>{foo}\alert<2>{bar}, which since \beamerpauses is 1 is the same as {foo}{bar}

  2. the \alt expands \alert<1>{bar}\alert<1>{foo}, which since \beamerpauses is 2 is the same as {bar}{foo}.

Advanced incremental-overlay-specification-fu involves offsetting \beamerpauses with numbers in parentheses such as \alert<.(2)->{foo}\alert<+->{bar}, which will alert first bar then both foo and bar. This is how you can have parts of a frame (for instance, parts of tikzpictures) change dynamically without having them all in the same order as they are typeset on the frame or hard-coding their slide numbers.

Edit Yossi asked if \alt really is "smart". If you look in the source code for beamerbaseoverlay.sty you find:

% \alt and \altenv

To me it looks the like the effect of \alt<#1>{#2}{#3} is that #2 and #3 are saved in macros which are expanded depending on whether #1 applies to the current frame. I don't understand expansion completely but I believe that when \def is scanning for parameter text it doesn't expand that text until the point of replacement (as opposed to \edef, which expands the parameter text before assigning it to #n). So yes, \alt is "smart" in the sense that conditionally included text is not expanded until it's included. I guess you could do a \tracingall to know for sure.

dangerous bend Late Edit

Couldn't help but paste in this frame I'm working on right now.

\begin{frame}[label=integral-of-x]{Example: Integral of $x$}
Find $\int_0^3 x\,dx$
\action<.->{For any $n$ we have $\alert<.(5)>{\Delta x = \frac{3}{n}}$ and for each $i$ between $0$ and $n$, $\alert<.(4)>{x_i = \frac{3i}{n}}$.}
\action<+->{For each $i$, take $x_i$ to represent the function on the $i$th interval.}
    \action<.->{\int_0^3 x\,dx = \lim_{n\to\infty} R_n }
        \action<+->{&= \lim_{n\to\infty} \sum_{i=1}^n \alert<.(1)>{f(x_i)}\,\alert<.(2)>{\Delta x}}
        \action<+->{ = \lim_{n\to\infty}\sum_{i=1}^n 
            \alert<+>{\left(\frac{\alert<.(1)>{3}}{\alert<.(1)>{n}}\right) }\\}
        \action<+->{&= \lim_{n\to\infty}\alert<.>{\frac{9}{n^2}} \alert<.(1)>{\sum_{i=1}^n i}}
        \action<+->{ = \alert<.(1)>{\lim_{n\to\infty}}\frac{9}{\alert<.(1)>{n^2}} 
            \cdot \alert<.>{\frac{\alert<.(1)>{n(n+1)}}{2}}}
        \action<+->{= \frac{9}{2}\alert<.>{\cdot 1}}

sample code output

  • The final example alerts first bar then both. An extra "-" slipped in there maybe?
    – Seamus
    Dec 2, 2010 at 13:31
  • @Seamus: that's what I meant. When I said "then foo" I didn't add "and no longer bar". But I'll edit it to be more clear. Dec 2, 2010 at 13:42
  • Your comment about \alt being smart, is at the heart of what I am asking...it is smart? does it gobble up the inactive term? what is the value of the counter after the alt is done? which terms incremented it? Dec 2, 2010 at 15:00
  • @Yossi: see edit. (1,2) yes (3) 3 on slide 1 and 2 on slide 2 (4) any + that's encountered for the first time between angle brackets. Dec 2, 2010 at 15:34
  • 1
    @Dr.ManuelKuehner seven years later I finally know how to quickly convert a PDF file to an animated GIF. So yes, see my edit. Jun 20, 2017 at 20:05

From the following simple example, it looks like the \alert inside the \alt is deciding what the second slide should be, and this overwrites whatever the second argument in \alt thinks it should be.

  \alert<+>{foo} bar%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .