Reading the following quote from the beamer
manual, I was left a bit confused:
When you write
<.->
, a similar thing as in<+->
happens except that the counterbeamerpauses
is not
incremented and except that you get the value ofbeamerpauses
decreased by one. Thus a dot, possibly followed
by an offset, just expands to the current value of the counterbeamerpauses
minus one, possibly offset.
I had difficulties in parsing the last sentence, and I found that I cannot answer any of the following questions:
- Should the specified offset be negative or positive?
- How should the offset be specified? The manual does not provide any examples.
- Is the offset incremented (or perhaps) decremented before it is being applied?
- What's the value of the
beamerpauses
counter within the code to which the overlay is applied? - What's the value of this counter after the specification?
Minimal Non-Working Example
To understand this better, I created the following minimal example, which does not compile.
\documentclass{beamer}
\begin{document}
\newcommand\cn{{\small\emph{\textbf{Beamer pauses is \arabic{beamerpauses}}}}}
\begin{frame}[fragile]\frametitle{Dot Notation in Overlays}
\begin{enumerate}
\item This is my first item, no overlay specification; \cn
\item<+-> This is my second item, overlay specification is \verb/<+->/; \cn
\item<.-> This is my third item, overlay specification is \verb/<.->/; \cn
\item This is my fourth item, no overlay specification; \cn
\item<.-> This is my fifth item, overlay specification is \verb/<.->/; \cn
\item<.(1)-> This is my sixth item, overlay specification is \verb/<.(1)->/; \cn
\item This is my seventh item, no overlay specification; \cn
\item<.(-1)-> This is my eighth item, overlay specification is \verb/<.(-1)->/; \cn
\item This is my ninth item, no overlay specification; \cn
\item<.(-2)-> This is my tenth item, overlay specification is \verb/<.(-2)->/; \cn
\item This is my eleventh item, no overlay specification; \cn
\item<.(+1)-> This is my twelfth item, overlay specification is \verb/<.(+1)->/; \cn
\item This is my thirteenth item, no overlay specification; \cn
\item<.(+2)-> This is my fourteenth item, overlay specification is \verb/<.(+2)->/; \cn
\item This is my fifteenth and final item, with no overlay specification; \cn
\end{enumerate}
\end{frame}
\end{document}
The error message I got was:
Runaway argument?
! File ended while scanning use of \next.
<inserted text>
\par
<*> myfile.tex
?
My requests is then: can you help my compile this example, and, more importantly, explain the output in view of the general principles I failed to discover.
Minimal Working Example
The following example explains what I have discovered so far, also based on the discussion below.
\documentclass{beamer}
\usepackage{color}
\newcommand\red[1]{\textcolor{red}{#1} }
\newcommand\blue[1]{\textcolor{blue}{#1} }
\makeatletter
\newcommand*{\overlaynumber}{\number\beamer@slideinframe}
\makeatother
\newcommand\noOverlay{\red{No OS---permanent} \cn}
\newcommand\plusMinus{\blue{OS is \texttt{<+->};} \cn}
\usepackage{multicol}\raggedcolumns
\newcommand\ct{\texttt{\textbackslash{}beamerpauses}}
\newcommand\cn{\hfill\textcolor{green!50!black}{\tiny\ct=\arabic{beamerpauses}}}
\begin{document}
\scriptsize
\renewcommand\baselinestretch{0.8}
\begin{frame}\frametitle{Beamer's Overlay Specification (OS) With \texttt{<.$X$>}}
\alert{\textbf{Slide \#\overlaynumber}}
\begin{multicols*}{2}
\begin{enumerate}
\item\noOverlay
\item<+->\plusMinus
\item<+->\plusMinus
\item<+->\plusMinus
\item\noOverlay
\item<.->OS \texttt{<.->} means \emph{present with last overlay},
without advancing \ct; \cn
\item\noOverlay
\item<.(0)->OS \texttt{<.(0)->} is just the same as \texttt{<.->}; \cn
\item<.-> in fact, all consecutive occurrences of the \texttt{<.->} OS are displayed together. \cn
\item\noOverlay
\item\plusMinus
\item<.(-1)-> OS, \texttt{<.(-1)->} means: present the overlayed
content \emph{\underline{two} slides before} the current value of \ct; \ct{} does not change; \cn
\item<+->\plusMinus
\item<+->\plusMinus
\item<.(-2)-> OS \texttt{<.(-2)->} means: present the overlayed
content \emph{\underline{three} slides before} the current value of counter \ct; as usual, the counter \ct{} does not change; \cn
\item\noOverlay
\item<.(1)-> OS \texttt{<.(1)->} means:
present with \emph{current} overlay; do not advance \ct; \cn
\item\noOverlay
\item<.(2)-> OS \texttt{<.(2)->} means:
present with \emph{next} overlay; do not advance \ct; \cn
\item<.(3)-> Similarly, OS \texttt{<.(3)->} means:
present with overlay \emph{after the next}; as usual, do not advance \ct; \cn
\item\noOverlay
\item<+->\plusMinus
\item\noOverlay
\item<+->\plusMinus
\item<+->\plusMinus
\item<+->\plusMinus
\end{enumerate}
\end{multicols*}
\end{frame}
\end{document}
Best Answer
Before looking at how
.
works, I think it's worth a brief look at how+
works as in an overlay specification, and to link that to a 'plain' specification containing only explicit numbers. I'll take the offsets last, as they are more complex.For the simple case of just numbers
the idea is pretty clear: something with a overlay spec
1-
appears on the first slide and any later slides, while more complex set ups (such as<1,3-5,7>
) are also possible and human-readable.In the case of
+
, whenbeamer
reads an overlay spec if replaces all of the+
tokens by the current value of thebeamerpauses
counter, then increments the counter (to apply to the next case it finds). Thus assuming there are no other overlays in the frame,is equivalent to the previous example: the first
+
is replaced by1
, the second by2
and the third by3
.The idea of
.
is it allows you to have two (or more) overlay specs which will be equivalent. For example, if we wanted to dowithout hard-coding the numbers we can't just use
+
. Instead, we can use.
, which really means 'repeat the last value ofbeamerpauses
':Here, in the first line
beamerpauses
is1
, so the+
becomes1
. In the second line, that value then gets repeated so the.
is replaced by a1
. In the third line,beamerpauses
is2
(because of the+
on the first line), so we end up with the same as my hard-coded case.Notice that while the
beamer
manual is describing what actaully happens at a code level, thinking about.
as being 'repeat the value used for the last+
' is conceptually easier and is equivalent in outcome. (Substitution always usesbeamerpauses
, and because+
increments it you have to take one back off to get.
to do the correct thing.)This then brings us to the offset business, which is quite advanced. Again, if we take a hard-coded demo first, we might have
which can be done 'flexibly' as
The idea here is that the bracketed value 'adjusts' the substitution, so the
+
symbols here are replaced by a value 'one ahead' of what they would normally be. Notice thatbeamerpauses
is still 'correct', so in the example above it's1
in the first line,2
in the second, etc.Exactly the same then applies in the
.
syntaxbut as the last line shows,
beamerpauses
isn't incremented.The idea of the bracket syntax is to allow relative offsets without fixing the absolute overlay numbers. However, it's down to you to make sure the values are sensible. In the question, the line
leads to an error because the last
+
was replaced by a1
. Thus taking 2 off it gives an overlay number of-1
, which is invalid. Thebeamer
code doesn't do a sanity test so you get a low-level error: that perhaps could be corrected, but really you need to watch your offsets!Another thing to note is is that your really don't want to have 'extra'
+
symbols in your overlay. For example, in the lineThe
+
is replaced by the current value ofbeamerpauses
in the normal way, so this line first gets converted toand then the offset is applied: slide 22! Presumably you wanted
i.e. one slide on from the current one, so in the example in the question slide 2.
To give an example where you might want to use these offsets, imagine that you want the first and third lines of an itemize to appear together, then the second and fourth lines, but you don't want to hard-code the slide numbers.
This only creates 2 overlays, with the two later items set to appear based on their relative relationship to the second item: the last one where
+
was used and sobeamerpauses
was altered.As requested, answering the specific points in the question:
Should the specified offset be negative or positive?
+
, and should only be negative when this keeps the value 'in range' (the absolute value of the overlay should remain positive).How should the offset be specified?
+
, e.g.,<.(1)->
,<.(2)->
, etc.Is the offset incremented (or perhaps) decremented before it is being applied?
<.->
is the same as writing<.(0)->
.What's the value of the
beamerpauses
counter within the code to which the overlay is applied?What's the value of this counter after the specification?
+
is present in the overlay spec, the value ofbeamerpauses
is incremented by exactly one.