# Local scope for beamer overlay specifications?

Suppose you have a large and complex piece of code that, for instance, draws part-by-part a TikZ picture in a beamer frame, with complex overlay and action specifications. Suppose also that the code does not use <+> and <.> overlays a lot because the intended sequence was too complex for them.

Now suppose you want to reuse this code in another presentation, but in a frame where this complex sequence of slides should start from the second or the third slide because now you want to show something else before.

Do you have to go through all your code adding +3 to the indices of every overlay specification? Or is there any way to scope a piece of code pretending that overlay specifications starts from 1 when instead they are starting from, say, 3?

\begin{overlayscope}{3}
\only<1>{LoL}
\end{overlayscope}


should be roughly equal to:

\only<4>{LoL}


Is it even possible? I don't know if the semantics is right either, for example, a <0> specification is often used to say "invisible", and adding an offset would maybe have unintended effects. But it would be a nice start.

A bit tricky, but with 3 features of beamer this should be doable:

1) You can tell beamer to only show certain overlays in a slide with \begin{frame}<4>.

2) And with \againframe<1-3>{<label name>} you can "reuse" slides

So with 1) and 2) we can effectivly reorder the order the overlays are presented. So you can add your new stuff, which should come first, at the end of the slides.

3) The last thing is to hide the previous content on the last (now first) slide. This can be done by \visible<1-3>{ or similar functions.

\documentclass{beamer}

\begin{document}

\begin{frame}<4>[label=myframe]
\only<1-4>{something new should be before}

\visible<1-3>{
\only<1->{1}
\only<2->{2}
\only<3->{3}
}

\end{frame}

% to keep the framenumber constant

\againframe<1-3>{myframe}

\end{document}


• Wow... Is the frame number also going to stay the same? Jul 6, 2016 at 8:38
• @gigabytes No, but to can make it stay the same with \addtocounter{framenumber}{-1} in front of the again-frame Jul 6, 2016 at 8:57
• You're right! Wondering if this trick can be packaged and automated in some way. Jul 6, 2016 at 9:16
• @gigabytes As I consider this a bit fiddled, I doubt it would make a good package. What I would find more useful, if beamer would stick to the order of overlays given e.g. \begin{frame}<4,1> would display 4 before 1 Jul 6, 2016 at 12:10

A simple solution would be to trick beamer and decrease the slideinframe-counter by 1. This seems a bit too easy, so maybe this breaks something else -- use at your own risk.

\documentclass{beamer}

\makeatletter
\newcommand{\trickbeamer}{%
}%
\makeatother

\begin{document}

\begin{frame}
bla
\pause\trickbeamer
\only<1->{1}
\only<2->{2}
\only<3->{3}
\end{frame}

\end{document}