Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

We all use the \onslide command inside the overprint environment in beamer. However, I find that assigning hard coded slide values, like \onslide<5> in this environment is really cumbersome. This situation becomes difficult whenever we have to insert a new slide in the middle of twenty some overlay slides. We have to manually renumber every subsequent slide after a new slide is inserted. That is why, I tried to define a \nextslide command in beamer.

The idea is very simple, the \nextslide command will increment a predefined counter and will use this value with the \onslide command.

\documentclass{beamer}

\newcounter{slidecounter}
\setcounter{slidecounter}{0}
\def\nextslide{\addtocounter{slidecounter}{1}\onslide<\value{slidecounter}>}

\begin{document}

\begin{frame}{Title}

  \begin{overprint}
    \nextslide
    On one

    \nextslide
    On two

  \end{overprint}

\end{frame}

\end{document}

I understand that I still need to implement resetting the counter at the start of overprint environment once I am successful with this part.

However, whenever I run the code with pdflatex, it keeps on generating page after page, which I have to interrupt with Ctrl-C.

[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46] [47] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67] [68] [69] [70] [71] [72] [73] [74]^C ! Interruption. \pgfsysprotocol@literalbuffered ...tocol@temp {{#1 \space }}\expandafter \pgf... l.20 \end{frame} ? x

The beamer code is too myriad for me to find out where this infinite loop is happening.

Any suggestion will be appreciated.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

That's what the + overlay specification is made for (cf. the beamer user guide, section 9.6.4):

The effect of the +-sign is the following: You can use it in any overlay specification at any point where you would usually use a number. If a +-sign is encountered, it is replaced by the current value of the LaTeX counter beamerpauses, which is 1 at the beginning of the frame. Then the counter is increased by 1, though it is only increased once for every overlay specification, even if the specification contains multiple +-signs (they are replaced by the same number).

So your MWE can be solved with

\documentclass{beamer}
\begin{document}
\begin{frame}{Title}
  \begin{overprint}
    \onslide<+>
    On one
    \onslide<+>
    On two
    \onslide<+>
    On three
  \end{overprint}
\end{frame}
\end{document}
share|improve this answer
    
Oh, goodness, I feel like a fool. Still, I would like to know what caused the infinite loop. –  Masroor Mar 20 '13 at 17:22
    
@MMA The problem is that the slide is compiled each time an overlay is typeset, so slidecounter is increased by 2 and such produces new overlays: For example, on the second overlay, \onslide<3> and \onslide<4> are executed, such creating two new pages etc. If you use \setcounter{slidecounter}{0} at the beginning of the frame, this won't happen and your MWE will produce the expected result. –  diabonas Mar 20 '13 at 17:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.