Debian Codegraph @

texmf-dist/doc/latex/beamer/beamerug-overlays.tex

raw
1 % !TeX root = beameruserguide.tex
2 % Copyright 2003-2007 by Till Tantau
3 % Copyright 2010 by Vedran Mileti\'c
4 % Copyright 2011-2015 by Vedran Mileti\'c, Joseph Wright
5 % Copyright 2017,2018 by Louis Stuart, Joseph Wright
6 % Copyright 2022-2026 by Joseph Wright, samcarter
7 %
8 % This file may be distributed and/or modified
9 %
10 % 1. under the LaTeX Project Public License and/or
11 % 2. under the GNU Free Documentation License.
12 %
13 % See the file LICENSE.md for more details.
14
15 \section{Creating Overlays}
16 \label{section-overlay}
17
18
19 \subsection{The Pause Commands}
20
21 The |pause| command offers an easy, but not very flexible way of creating frames that are uncovered piecewise. If you say |\pause| somewhere in a frame, only the text on the frame up to the |\pause| command is shown on the first slide. On the second slide, everything is shown up to the second |\pause|, and so forth. You can also use |\pause| inside environments; its effect will last after the environment. However, taking this to extremes and using |\pause| deeply within a nested environment may not have the desired result.
22
23 A much more fine-grained control over what is shown on each slide can be attained using overlay specifications, see the next sections. However, for many simple cases the |\pause| command is sufficient.
24
25 The effect of |\pause| lasts till the next |\pause|, |\onslide|, or the end of the frame.
26 \begin{verbatim}
27 \begin{frame}
28 \begin{itemize}
29 \item
30 Shown from first slide on.
31 \pause
32 \item
33 Shown from second slide on.
34 \begin{itemize}
35 \item
36 Shown from second slide on.
37 \pause
38 \item
39 Shown from third slide on.
40 \end{itemize}
41 \item
42 Shown from third slide on.
43 \pause
44 \item
45 Shown from fourth slide on.
46 \end{itemize}
47
48 Shown from fourth slide on.
49
50 \begin{itemize}
51 \onslide
52 \item
53 Shown from first slide on.
54 \pause
55 \item
56 Shown from fifth slide on.
57 \end{itemize}
58 \end{frame}
59 \end{verbatim}
60
61 \begin{command}{\pause\oarg{number}}
62 This command causes the text following it to be shown only from the next slide on, or, if the optional \meta{number} is given, from the slide with the number \meta{number}. If the optional \meta{number} is given, the counter |beamerpauses| is set to this number. This command uses the |\onslide| command, internally. This command does \emph{not} work correctly inside |amsmath| environments like |align| and \pgfname\ environements like |tikzpicture| or |tcolorbox|, since these do really wicked things.
63
64 \example
65 \begin{verbatim}
66 \begin{frame}
67 \begin{itemize}
68 \item
69 A
70 \pause
71 \item
72 B
73 \pause
74 \item
75 C
76 \end{itemize}
77 \end{frame}
78 \end{verbatim}
79
80 \articlenote
81 This command is ignored.
82
83 \end{command}
84
85 To ``unpause'' some text, that is, to temporarily suspend pausing, use the command |\onslide|, see below.
86
87
88 \subsection{The General Concept of Overlay Specifications}
89 \label{section-concept-overlays}
90
91 The approach taken by most presentation classes to overlays is somewhat similar to the above |\pause| command. These commands get a certain slide number as input and affect the text on the slide following this command in a certain way. For example, \textsc{prosper}'s |\FromSlide{2}| command causes all text following this command to be shown only from the second slide on.
92
93 The \beamer\ class uses a different approach (though the abovementioned command is also available: |\onslide<2->| will have the same effect as |\FromSlide{2}|, except that |\onslide| transcends environments; likewise, |\pause| is internally mapped to a command with an appropriate overlay specification). The idea is to add \emph{overlay specifications} to certain commands. These specifications are always given in pointed brackets and follow the command ``as soon as possible,'' though in certain cases \beamer\ also allows overlay specification to be given a little later. In the simplest case, the specification contains just a number. A command with an overlay specification following it will only have ``effect'' on the slide(s) mentioned in the specification. What exactly ``having an effect'' means, depends on the command. Consider the following example.
94 \begin{verbatim}
95 \begin{frame}
96 \textbf{This line is bold on all three slides.}
97 \textbf<2>{This line is bold only on the second slide.}
98 \textbf<3>{This line is bold only on the third slide.}
99 \end{frame}
100 \end{verbatim}
101
102 For the command |\textbf|, the overlay specification causes the text to be set in boldface only on the specified slides. On all other slides, the text is set in a normal font.
103
104 For a second example, consider the following frame:
105 \begin{verbatim}
106 \begin{frame}
107 \only<1>{This line is inserted only on slide 1.}
108 \only<2>{This line is inserted only on slide 2.}
109 \end{frame}
110 \end{verbatim}
111
112 The command |\only|, which is introduced by \beamer, normally simply inserts its parameter into the current frame. However, if an overlay specification is present, it ``throws away'' its parameter on slides that are not mentioned.
113
114 Overlay specifications can only be written behind certain commands, not every command. Which commands you can use and which effects this will have is explained in the next section. However, it is quite easy to redefine an existing command such that it becomes ``overlay specification aware,'' see also Section~\ref{section-overlay-commands}.
115
116 The syntax of (basic) overlay specifications is the following: They are comma-separated lists of slides and ranges. Ranges are specified like this: |2-5|, which means slide two through to five. The start or the end of a range can be omitted. For example, |3-| means ``slides three, four, five, and so on'' and |-5| means the same as |1-5|. A complicated example is |-3,6-8,10,12-15|, which selects the slides 1, 2, 3, 6, 7, 8, 10, 12, 13, 14, and 15.
117
118
119 \subsection{Commands with Overlay Specifications}
120 \label{section-overlay-commands}
121
122 \textbf{Important:} Due to the way overlay specifications are implemented, the
123 commands documented here are \emph{all} fragile even if the \LaTeXe{} kernel
124 versions are not.
125
126 For the following commands, adding an overlay specification causes the command to be simply ignored on slides that are not included in the specification: |\textbf|, |\textit|, |\textmd|, |\textnormal|, |\textrm|, |\textsc|, |\textsf|, |\textsl|, |\texttt|, |\textup|, |\emph|; |\color|, |\textcolor|; |\alert|, |\structure|. If a command takes several arguments, like |\color|, the specification should directly follow the command as in the following example (but there are exceptions to this rule):
127 \begin{verbatim}
128 \begin{frame}
129 \color<2-3>[rgb]{1,0,0} This text is red on slides 2 and 3, otherwise black.
130 \end{frame}
131 \end{verbatim}
132
133 For the following commands, the effect of an overlay specification is special:
134
135 \begin{command}{\onslide\opt{\meta{modifier}}\sarg{overlay specification}\opt{\marg{text}}}
136 The behavior of this command depends on whether the optional argument \meta{text} is given or not (note that the optional argument is given in \emph{normal} braces, not in square brackets). If present, the \meta{modifier} can be either a~|+| or a~|*|.
137
138 If no \meta{text} is given, the following happens: All text following this command will only be shown (uncovered) on the specified slides. On non-specified slides, the text still occupies space. If no slides are specified, the following text is always shown. You need not call this command in the same \TeX\ group, its effect transcends block groups. However, this command has a \emph{different} effect inside an |overprint| environment, see the description of |overprint|.
139
140 If the \meta{modifier} is |+|, hidden text will not be treated as covered, but as invisible. The difference is the same as the difference between |\uncover| and |\visible|. The modifier |*| may not be given if no \meta{text} argument is present.
141
142 \example
143 \begin{verbatim}
144 \begin{frame}
145 Shown on first slide.
146 \onslide<2-3>
147 Shown on second and third slide.
148 \begin{itemize}
149 \item
150 Still shown on the second and third slide.
151 \onslide+<4->
152 \item
153 Shown from slide 4 on.
154 \end{itemize}
155 Shown from slide 4 on.
156 \onslide
157 Shown on all slides.
158 \end{frame}
159 \end{verbatim}
160
161 If a \meta{text} argument is present, |\onslide| (without a \meta{modifier}) is mapped to |\uncover|, |\onslide+| is mapped to |\visible|, and |\onslide*| is mapped to |\only|.
162
163 \example
164 \begin{verbatim}
165 \begin{frame}
166 \onslide<1>{Same effect as the following command.}
167 \uncover<1>{Same effect as the previous command.}
168
169 \onslide+<2>{Same effect as the following command.}
170 \visible<2>{Same effect as the previous command.}
171
172 \onslide*<3>{Same effect as the following command.}
173 \only<3>{Same effect as the previous command.}
174 \end{frame}
175 \end{verbatim}
176 \end{command}
177
178 \begin{command}{\only\sarg{overlay specification}\marg{text}\sarg{overlay specification}}
179 If either \meta{overlay specification} is present (though only one may be present), the \meta{text} is inserted only into the specified slides. For other slides, the text is simply thrown away. In particular, it occupies no space.
180
181 \example
182 |\only<3->{Text inserted from slide 3 on.}|
183
184 Since the overlay specification may also be given after the text, you can often use |\only| to make other commands overlay specification-aware in a simple manner:
185
186 \example
187 \begin{verbatim}
188 \newcommand{\myblue}{\only{\color{blue}}}
189 \begin{frame}
190 \myblue<2> This text is blue only on slide 2.
191 \end{frame}
192 \end{verbatim}
193 \end{command}
194
195 \begin{command}{\uncover\sarg{overlay specification}\marg{text}}
196 If the \meta{overlay specification} is present, the \meta{text} is shown (``uncovered'') only on the specified slides. On other slides, the text still occupies space and it is still typeset, but it is not shown or only shown as if transparent. For details on how to specify whether the text is invisible or just transparent see Section~\ref{section-transparent}.
197
198 \example
199 |\uncover<3->{Text shown from slide 3 on.}|
200
201 \articlenote
202 This command has the same effect as |\only|.
203 \end{command}
204
205 \begin{command}{\visible\sarg{overlay specification}\marg{text}}
206 This command does almost the same as |\uncover|. The only difference is that if the text is not shown, it is never shown in a transparent way, but rather it is not shown at all. Thus, for this command the transparency settings have no effect.
207
208 \example
209 |\visible<2->{Text shown from slide 2 on.}|
210
211 \articlenote
212 This command has the same effect as |\only|.
213 \end{command}
214
215 \begin{command}{\invisible\sarg{overlay specification}\marg{text}}
216 This command is the opposite of |\visible|.
217
218 \example
219 |\invisible<-2>{Text shown from slide 3 on.}|
220 \end{command}
221
222 \begin{command}{\alt\sarg{overlay specification}\marg{default text}\marg{alternative text}\sarg{overlay specification}}
223 Only one \meta{overlay specification} may be given. The default text is shown on the specified slides, otherwise the alternative text. The specification must always be present.
224
225 \example
226 |\alt<2>{On Slide 2}{Not on slide 2.}|
227
228 Once more, giving the overlay specification at the end is useful when the command is used inside other commands.
229
230 \example
231 Here is the definition of |\uncover|:
232 \begin{verbatim}
233 \newcommand{\uncover}{\alt{\@firstofone}{\makeinvisible}}
234 \end{verbatim}
235 \end{command}
236
237 \begin{command}{\temporal\ssarg{overlay specification}\marg{before slide text}\marg{default text}\marg{after slide text}}
238 This command alternates between three different texts, depending on whether the current slide is temporally before the specified slides, is one of the specified slides, or comes after them. If the \meta{overlay specification} is not an interval (that is, if it has a ``hole''), the ``hole'' is considered to be part of the before slides.
239
240 \example
241 \begin{verbatim}
242 \temporal<3-4>{Shown on 1, 2}{Shown on 3, 4}{Shown 5, 6, 7, ...}
243 \temporal<3,5>{Shown on 1, 2, 4}{Shown on 3, 5}{Shown 6, 7, 8, ...}
244 \end{verbatim}
245
246 As a possible application of the |\temporal| command consider the following example:
247
248 \example
249 \begin{verbatim}
250 \def\colorize<#1>{%
251 \temporal<#1>{\color{red!50}}{\color{black}}{\color{black!50}}}
252
253 \begin{frame}
254 \begin{itemize}
255 \colorize<1> \item First item.
256 \colorize<2> \item Second item.
257 \colorize<3> \item Third item.
258 \colorize<4> \item Fourth item.
259 \end{itemize}
260 \end{frame}
261 \end{verbatim}
262 \end{command}
263
264
265 \begin{command}{\item\sarg{alert specification}\oarg{item label}\sarg{alert specification}}
266 \beamernote
267 Only one \meta{alert specification} may be given. The effect of \meta{alert specification} is described in Section~\ref{section-action-specifications}.
268
269 \example
270 \begin{verbatim}
271 \begin{frame}
272 \begin{itemize}
273 \item<1-> First point, shown on all slides.
274 \item<2-> Second point, shown on slide 2 and later.
275 \item<2-> Third point, also shown on slide 2 and later.
276 \item<3-> Fourth point, shown on slide 3.
277 \end{itemize}
278 \end{frame}
279
280 \begin{frame}
281 \begin{enumerate}
282 \item<3-| alert@3>[0.] A zeroth point, shown at the very end.
283 \item<1-| alert@1> The first and main point.
284 \item<2-| alert@2> The second point.
285 \end{enumerate}
286 \end{frame}
287 \end{verbatim}
288
289 \articlenote
290 The \meta{action specification} is currently completely ignored.
291
292 \end{command}
293
294 The related command |\bibitem| is also overlay specification-aware in the same way as |\item|.
295
296 \begin{command}{\label\sarg{overlay specification}\marg{label name}}
297 If the \meta{overlay specification} is present, the label is only inserted on the specified slide. Inserting a label on more than one slide will cause a `multiple labels' warning. \emph{However}, if no overlay specification is present, the specification is automatically set to just `1' and the label is thus inserted only on the first slide. This is typically the desired behavior since it does not really matter on which slide the label is inserted, \emph{except} if you use an |\only| command and \emph{except} if you wish to use that label as a hyperjump target. Then you need to specify a slide.
298
299 Labels can be used as target of hyperjumps. A convenient way of labelling a frame is to use the |label=|\meta{name} option of the |frame| environment. However, this will cause the whole frame to be kept in memory till the end of the compilation, which may pose a problem.
300
301 \example
302 \begin{verbatim}
303 \begin{frame}
304 \begin{align}
305 a &= b + c \label{first}\\ % no specification needed
306 c &= d + e \label{second}% no specification needed
307 \end{align}
308
309 Blah blah, \uncover<2>{more blah blah.}
310
311 \only<3>{Specification is needed now.\label<3>{mylabel}}
312 \end{frame}
313 \end{verbatim}
314 \end{command}
315
316
317 \subsection{Environments with Overlay Specifications}
318
319 Environments can also be equipped with overlay specifications. For most of the predefined environments, see Section~\ref{predefined}, adding an overlay specification causes the whole environment to be uncovered only on the specified slides. This is useful for showing things incrementally as in the following example.
320 \begin{verbatim}
321 \begin{frame}
322 \frametitle{A Theorem on Infinite Sets}
323
324 \begin{theorem}<1->
325 There exists an infinite set.
326 \end{theorem}
327
328 \begin{proof}<3->
329 This follows from the axiom of infinity.
330 \end{proof}
331
332 \begin{example}<2->
333 The set of natural numbers is infinite.
334 \end{example}
335 \end{frame}
336 \end{verbatim}
337
338 In the example, the first slide only contains the theorem, on the second slide an example is added, and on the third slide the proof is also shown.
339
340 For each of the basic commands |\only|, |\alt|, |\visible|, |\uncover|, and |\invisible| there exists ``environment versions'' |onlyenv|, |altenv|, |visibleenv|, |uncoverenv|, and |invisibleenv|. Except for |altenv| and |onlyenv|, these environments do the same as the commands.
341
342 \begin{environment}{{onlyenv}\sarg{overlay specification}}
343 If the \meta{overlay specification} is given, the contents of the environment is inserted into the text only on the specified slides. The difference to |\only| is, that the text is actually typeset inside a box that is then thrown away, whereas |\only| immediately throws away its contents. If the text is not ``typesettable,'' the |onlyenv| may produce an error where |\only| would not.
344
345 \example
346 \begin{verbatim}
347 \begin{frame}
348 This line is always shown.
349 \begin{onlyenv}<2>
350 This line is inserted on slide 2.
351 \end{onlyenv}
352 \end{frame}
353 \end{verbatim}
354 \end{environment}
355
356 \begin{environment}{{altenv}\sarg{overlay specification}\marg{begin text}\marg{end text}\marg{alternate begin text}\marg{alternate end text}\sarg{overlay specification}}
357 Only one \meta{overlay specification} may be given. On the specified slides, \meta{begin text} will be inserted at the beginning of the environment and \meta{end text} will be inserted at the end. On all other slides, \meta{alternate begin text} and \meta{alternate end text} will be used.
358
359 \example
360 \begin{verbatim}
361 \begin{frame}
362 This
363 \begin{altenv}<2>{(}{)}{[}{]}
364 word
365 \end{altenv}
366 is in round brackets on slide 2 and in square brackets on slide 1.
367 \end{frame}
368 \end{verbatim}
369 \end{environment}
370
371
372 \subsection{Dynamically Changing Text or Images}
373
374 You may sometimes wish to have some part of a frame change dynamically from slide to slide. On each slide of the frame, something different should be shown inside this area. You could achieve the effect of dynamically changing text by giving a list of |\only| commands like this:
375 \begin{verbatim}
376 \only<1>{Initial text.}
377 \only<2>{Replaced by this on second slide.}
378 \only<3>{Replaced again by this on third slide.}
379 \end{verbatim}
380
381 The trouble with this approach is that it may lead to slight, but annoying differences in the heights of the lines, which may cause the whole frame to ``wobble'' from slide to slide. This problem becomes much more severe if the replacement text is several lines long.
382
383 To solve this problem, you can use two environments: |overlayarea| and |overprint|. The first is more flexible, but less user-friendly.
384
385 \begin{environment}{{overlayarea}\marg{area width}\marg{area height}}
386 Everything within the environment will be placed in a rectangular area of the specified size. The area will have the same size on all slides of a frame, regardless of its actual contents.
387
388 \example
389 \begin{verbatim}
390 \begin{overlayarea}{\textwidth}{3cm}
391 \only<1>{Some text for the first slide.\\Possibly several lines long.}
392 \only<2>{Replacement on the second slide.}
393 \end{overlayarea}
394 \end{verbatim}
395
396 \end{environment}
397
398 \begin{environment}{{overprint}\oarg{area width}}
399 The \meta{area width} defaults to the text width. Inside the environment, use |\onslide| commands to specify different things that should be shown for this environment on different slides. The |\onslide| commands are used like |\item| commands. Everything within the environment will be placed in a rectangular area of the specified width. The height and depth of the area are chosen large enough to accommodate the largest contents of the area. The overlay specifications of the |\onslide| commands must be disjoint. This may be a problem for handouts, since, there, all overlay specifications default to |1|. If you use the option |handout|, you can disable all but one |\onslide| by setting the others to |0|.
400
401 \example
402 \begin{verbatim}
403 \begin{overprint}
404 \onslide<1| handout:1>
405 Some text for the first slide.\\
406 Possibly several lines long.
407 \onslide<2| handout:0>
408 Replacement on the second slide. Suppressed for handout.
409 \end{overprint}
410 \end{verbatim}
411
412 \end{environment}
413
414 A similar need for dynamical changes arises when you have, say, a series of pictures named |first.pdf|, |second.pdf|, and |third.pdf| that show different stages of some process. To make a frame that shows these pictures on different slides, the following code might be used:
415 \begin{verbatim}
416 \begin{frame}
417 \frametitle{The Three Process Stages}
418
419 \includegraphics<1>{first.pdf}
420 \includegraphics<2>{second.pdf}
421 \includegraphics<3>{third.pdf}
422 \end{frame}
423 \end{verbatim}
424
425 The above code uses the fact the \beamer\ makes the |\includegraphics| command overlay specification-aware. It works nicely, but only if each |.pdf| file contains the complete graphic to be shown. However, some programs, like |xfig|, sometimes also produce series of graphics in which each file just contains the \emph{additional} graphic elements to be shown on the next slide. In this case, the first graphic must be shown not on overlay~1, but from overlay~1 on, and so on. While this is easy to achieve by changing the overlay specification |<1>| to |<1->|, the graphics must also be shown \emph{on top of each other}. An easy way to achieve this is to use \TeX's |\llap| command like this:
426 \begin{verbatim}
427 \begin{frame}
428 \frametitle{The Three Process Stages}
429
430 \includegraphics<1->{first.pdf}%
431 \llap{\includegraphics<2->{second.pdf}}%
432 \llap{\includegraphics<3->{third.pdf}}
433 \end{frame}
434 \end{verbatim}
435
436 or like this:
437 \begin{verbatim}
438 \begin{frame}
439 \frametitle{The Three Process Stages}
440
441 \includegraphics{first.pdf}%
442 \pause%
443 \llap{\includegraphics{second.pdf}}%
444 \pause%
445 \llap{\includegraphics{third.pdf}}
446 \end{frame}
447 \end{verbatim}
448
449 A more convenient way is to use the |\multiinclude| command, see Section~\ref{section-xmpmulti} for details.
450
451
452 \subsection{Advanced Overlay Specifications}
453
454 \subsubsection{Making Commands and Environments Overlay Specification-Aware}
455
456 This section explains how to define new commands that are overlay specification-aware. Also, it explains how to setup counters correctly that should be increased from frame to frame (like equation numbering), but not from slide to slide. You may wish to skip this section, unless you want to write your own extensions to the \beamer\ class.
457
458 \beamer\ extends the syntax of \LaTeX's standard command |\newcommand|:
459
460 \begin{command}{\newcommand\declare{|<>|}\marg{command name}\oarg{argument number}\oarg{default optional value}\marg{text}}
461 Declares the new command named \meta{command name}. The \meta{text} should contain the body of this command and it may contain occurrences of parameters like |#|\meta{number}. Here \meta{number} may be between 1 and $\mbox{\meta{argument number}}+1$. The additionally allowed argument is the overlay specification.
462
463 When \meta{command name} is used, it will scan as many as \meta{argument number} arguments. While scanning them, it will look for an overlay specification, which may be given between any two arguments, before the first argument, or after the last argument. If it finds an overlay specification like |<3>|, it will call \meta{text} with arguments 1 to \meta{argument number} set to the normal arguments and the argument number $\mbox{\meta{argument number}}+1$ set to |<3>| (including the pointed brackets). If no overlay specification is found, the extra argument is empty.
464
465 If the \meta{default optional value} is provided, the first argument of \meta{command name} is optional. If no optional argument is specified in square brackets, the \meta{default optional value} is used.
466
467 \example
468 The following command will typeset its argument in red on the specified slides:
469 \begin{verbatim}
470 \newcommand<>{\makered}[1]{{\color#2{red}#1}}
471 \end{verbatim}
472
473 \example
474 Here is \beamer's definition of |\emph|:
475 \begin{verbatim}
476 \newcommand<>{\emph}[1]{{\only#2{\itshape}#1}}
477 \end{verbatim}
478
479 \example
480 Here is \beamer's definition of |\transdissolve| (the command |\beamer@dotrans| mainly passes its argument to |hyperref|):
481 \begin{verbatim}
482 \newcommand<>{\transdissolve}[1][]{\only#2{\beamer@dotrans[#1]{Dissolve}}}
483 \end{verbatim}
484 \end{command}
485
486 \begin{command}{\renewcommand\declare{|<>|}\marg{existing command name}\oarg{argument number}\oarg{default optional value}\marg{text}}
487 Redeclares a command that already exists in the same way as |\newcommand<>|. Inside \meta{text}, you can still access to original definitions using the command |\beameroriginal|, see the example.
488
489 \example
490 This command is used in \beamer\ to make |\hyperlink| overlay specification-aware:
491 \begin{verbatim}
492 \renewcommand<>{\hyperlink}[2]{\only#3{\beameroriginal{\hyperlink}{#1}{#2}}}
493 \end{verbatim}
494 \end{command}
495
496 \begin{command}{\newenvironment\declare{|<>|}\marg{environment name}\oarg{argument number}\oarg{default optional value}\\ \marg{begin text}\marg{end text}}
497 Declares a new environment that is overlay specification-aware. If this environment is encountered, the same algorithm as for |\newcommand<>| is used to parse the arguments and the overlay specification.
498
499 Note that, as always, the \meta{end text} may not contain any arguments like |#1|. In particular, you do not have access to the overlay specification. In this case, it is usually a good idea to use |altenv| environment in the \meta{begin text}.
500
501 \example
502 Declare your own action block:
503 \begin{verbatim}
504 \newenvironment<>{myboldblock}[1]{%
505 \begin{actionenv}#2%
506 \textbf{#1}
507 \par}
508 {\par%
509 \end{actionenv}}
510
511 \begin{frame}
512 \begin{myboldblock}{A title for the theorem}<2>
513 This theorem is shown only on the second slide.
514 \end{myboldblock}
515 \end{frame}
516 \end{verbatim}
517
518 \example
519 Text in the following environment is bold on specified slides and of normal weight on non-specified slides:
520 \begin{verbatim}
521 \newenvironment<>{boldornormal}
522 {\begin{altenv}#1
523 {\begin{bfseries}}{\end{bfseries}}
524 {}{}}
525 {\end{altenv}}
526 \end{verbatim}
527
528 Incidentally, since |altenv| also accepts its argument at the end, the same effect could have been achieved using just
529 \begin{verbatim}
530 \newenvironment{boldornormal}
531 {\begin{altenv}
532 {\begin{bfseries}}{\end{bfseries}}
533 {}{}}
534 {\end{altenv}}
535 \end{verbatim}
536 \end{command}
537
538 \begin{command}{\renewenvironment\declare{|<>|}\marg{existing environment name}\oarg{argument number}\oarg{default optional value}\\ \marg{begin text}\marg{end text}}
539 Redefines an existing environment. The original environment is still available under the name |original|\meta{existing environment name}.
540
541 \example
542 \begin{verbatim}
543 \renewenvironment<>{center}
544 {\begin{actionenv}#1\begin{originalcenter}}
545 {\end{originalcenter}\end{actionenv}}
546 \end{verbatim}
547 \end{command}
548
549 In a similar way |\NewDocumentCommand|, |\NewDocumentEnvironment| etc.\ can be used to define overlay aware commands and environments. The overlay argument can be specified via |d<>| (without default value) or |D<>{}| (with default value) type arguments.
550
551 \example
552 \begin{verbatim}
553 \NewDocumentCommand{\makeblue}{D<>{.-} m}{{\color<#1>{blue}#2}}
554 \end{verbatim}
555
556 Note that by using |\NewDocumentCommand|, |\NewDocumentEnvironment| etc.\ the original definition of the command or environment won't be retained as |\beameroriginal{...}| or |\begin{original...}|.
557
558 The following two commands can be used to ensure that a certain counter is automatically reset on subsequent slides of a frame. This is necessary for example for the equation count. You might want this count to be increased from frame to frame, but certainly not from overlay slide to overlay slide. For equation counters and footnote counters (you should not use footnotes), these commands have already been invoked.
559
560 \begin{command}{\resetcounteronoverlays\marg{counter name}}
561 After you have invoked this command, the value of the specified counter will be the same on all slides of every frame.
562 \example
563 |\resetcounteronoverlays{equation}|
564 \end{command}
565
566 \begin{command}{\resetcountonoverlays\marg{count register name}}
567 The same as |\resetcounteronoverlays|, except that this command should be used with counts that have been created using the \TeX\ primitive |\newcount| instead of \LaTeX's |\definecounter|.
568 \example
569 \begin{verbatim}
570 \newcount\mycount
571 \resetcountonoverlays{mycount}
572 \end{verbatim}
573 \end{command}
574
575 \subsubsection{Mode Specifications}
576
577 This section is only important if you use \beamer's mode mechanism to create different versions of your presentation. If you are not familiar with \beamer's modes, please skip this section or read Section~\ref{section-modes} first.
578
579 In certain cases you may wish to have different overlay specifications to apply to a command in different modes. For example, you might wish a certain text to appear only from the third slide on during your presentation, but in a handout for the audience there should be no third slide and the text should appear already on the second slide. In this case you could write
580 \begin{verbatim}
581 \only<3| handout:2>{Some text}
582 \end{verbatim}
583
584 The vertical bar separates the two different specifications |3| and |handout:2|. By writing a mode name before a colon, you specify that the following specification only applies to that mode. If no mode is given, as in |3|, the mode |beamer| is automatically added. For this reason, if you write |\only<3>{Text}| and you are in |handout| mode, the text will be shown on all slides since there is no restriction specified for handouts and since the |3| is the same as |beamer:3|.
585
586 It is also possible to give an overlay specification that contains only a mode name (or several, separated by vertical bars):
587 \begin{verbatim}
588 \only<article>{This text is shown only in article mode.}
589 \end{verbatim}
590
591 An overlay specification that does not contain any slide numbers is called a (pure) \emph{mode specification}. If a mode specification is given, all modes that are not mentioned are automatically suppressed. Thus |<beamer:1->| means ``on all slides in |beamer| mode and also on all slides in all other modes, since nothing special is specified for them,'' whereas |<beamer>| means ``on all slides in |beamer| mode and not on any other slide.''
592
593 Mode specifications can also be used outside frames as in the following examples:
594 \begin{verbatim}
595 \section<presentation>{This section exists only in the presentation modes}
596 \section<article>{This section exists only in the article mode}
597 \end{verbatim}
598
599 Presentation modes include |beamer|, |trans| and |handout|.
600
601 You can also mix pure mode specifications and overlay specifications, although this can get confusing:
602 \begin{verbatim}
603 \only<article| beamer:1>{Riddle}
604 \end{verbatim}
605
606 This will cause the text |Riddle| to be inserted in |article| mode and on the first slide of a frame in |beamer| mode, but not at all in |handout| or |trans| mode. (Try to find out how \verb/<beamer| beamer:1>/ differs from |<beamer>| and from |<beamer:1>|.)
607
608 As if all this were not already complicated enough, there is another mode that behaves in a special way: the mode |second|. For this mode a special rule applies: An overlay specification for mode |beamer| also applies to mode |second| (but not the other way round). Thus, if we are in mode |second|, the specification |<second:2>| means ``on slide 2'' and |<beamer:2>| also means ``on slide 2''. To get a slide that is typeset in |beamer| mode, but not in |second| mode, you can use, |<second:0>|.
609
610 \subsubsection{Action Specifications}
611 \label{section-action-specifications}
612
613 This section also introduces a rather advanced concept. You may also wish to skip it on first reading.
614
615 Some overlay specification-aware commands can handle not only normal overlay specifications, but also so called \emph{action specifications}. In an action specification, the list of slide numbers and ranges is prefixed by \meta{action}|@|, where \meta{action} is the name of a certain action to be taken on the specified slides:
616 \begin{verbatim}
617 \item<3-| alert@3> Shown from slide 3 on, alerted on slide 3.
618 \end{verbatim}
619
620 In the above example, the |\item| command, which allows actions to be specified, will uncover the item text from slide three on and it will, additionally, alert this item exactly on slide 3.
621
622 Not all commands can take an action specification. Currently, only |\item| (though not in |article| mode currently), |\action|, the environment |actionenv|, and the block environments (like |block| or |theorem|) handle them.
623
624 By default, the following actions are available:
625 \begin{itemize}
626 \item \declare{|alert|} alters the item or block.
627 \item \declare{|uncover|} uncovers the item or block (this is the default, if no action is specified).
628 \item \declare{|only|} causes the whole item or block to be inserted only on the specified slides.
629 \item \declare{|visible|} causes the text to become visible only on the specified slides (the difference between |uncover| and |visible| is the same as between |\uncover| and |\visible|).
630 \item \declare{|invisible|} causes the text to become invisible on the specified slides.
631 \end{itemize}
632
633 The rest of this section explains how you can add your own actions and make commands action-specification-aware. You may wish to skip it upon first reading.
634
635 You can easily add your own actions: An action specification like \meta{action}|@|\meta{slide numbers} simply inserts an environment called \meta{action}|env| around the |\item| or parameter of |\action| with |<|\meta{slide numbers}|>| as overlay specification. Thus, by defining a new overlay specification-aware environment named \meta{my action name}|env|, you can add your own action:
636 \begin{verbatim}
637 \newenvironment{checkenv}{\only{\setbeamertemplate{itemize item}{X}}}{}
638 \end{verbatim}
639
640 You can then write
641 \begin{verbatim}
642 \item<beamer:check@2> Text.
643 \end{verbatim}
644
645 This will change the itemization symbol before |Text.| to |X| on slide~2 in |beamer| mode. The definition of |checkenv| used the fact that |\only| also accepts an overlay specification given after its argument.
646
647 The whole action mechanism is based on the following environment:
648
649 \begin{environment}{{actionenv}\sarg{action specification}}
650 This environment extracts all actions from the \meta{action specification} for the current mode. For each action of the form \meta{action}|@|\meta{slide numbers}, it inserts the following text: |\begin{|\meta{action}|env}<|\meta{slide number}|>| at the beginning of the environment and the text |\end{|\meta{action}|env}| at the end. If there are several action specifications, several environments are opened (and closed in the appropriate order). An \meta{overlay specification} without an action is promoted to |uncover@|\meta{overlay specification}.
651
652 If the so called \emph{default overlay specification} is not empty, it will be used in case no \meta{action specification} is given. The default overlay specification is usually just empty, but it may be set either by providing an additional optional argument to the command |\frame| or to the environments |itemize|, |enumerate|, or |description| (see these for details). Also, the default action specification can be set using the command |\beamerdefaultoverlayspecification|, see below.
653
654 \example
655 \begin{verbatim}
656 \begin{frame}
657 \begin{actionenv}<2-| alert@3-4,6>
658 This text is shown the same way as the text below.
659 \end{actionenv}
660
661 \begin{uncoverenv}<2->
662 \begin{alertenv}<3-4,6>
663 This text is shown the same way as the text above.
664 \end{alertenv}
665 \end{uncoverenv}
666 \end{frame}
667 \end{verbatim}
668 \end{environment}
669
670 \begin{command}{\action\sarg{action specification}\marg{text}}
671 This has the same effect as putting \meta{text} in an |actionenv|.
672
673 \example
674 |\action<alert@2>{Could also have used \alert<2>{}.}|
675 \end{command}
676
677 \begin{command}{\beamerdefaultoverlayspecification\marg{default overlay specification}}
678 Locally sets the default overlay specification to the given value. This overlay specification will be used in every |actionenv| environment and every |\item| that does not have its own overlay specification. The main use of this command is to install an incremental overlay specification like |<+->| or \verb/<+-| alert@+>/, see Section~\ref{section-incremental}.
679
680 Usually, the default overlay specification is installed automatically by the optional arguments to |\frame|, |frame|, |itemize|, |enumerate|, and |description|. You will only have to use this command if you wish to do funny things.
681
682 If given outside any frame, this command sets the default overlay specification for all following frames for which you do not override the default overlay specification.
683
684 \example
685 |\beamerdefaultoverlayspecification{<+->}|
686
687 \example
688 |\beamerdefaultoverlayspecification{}| clears the default overlay specification. (Actually, it installs the default overlay specification |<*>|, which just means ``always,'' but the ``portable'' way of clearing the default overlay specification is this call.)
689 \end{command}
690
691 \subsubsection{Incremental Specifications}
692 \label{section-incremental}
693
694 This section is mostly important for people who have already used overlay specifications a lot and have grown tired of writing things like |<1->|, |<2->|, |<3->|, and so on again and again. You should skip this section on first reading.
695
696 Often you want to have overlay specifications that follow a pattern similar to the following:
697 \begin{verbatim}
698 \begin{itemize}
699 \item<1-> Apple
700 \item<2-> Peach
701 \item<3-> Plum
702 \item<4-> Orange
703 \end{itemize}
704 \end{verbatim}
705
706 The problem starts if you decide to insert a new fruit, say, at the beginning. In this case, you would have to adjust all of the overlay specifications. Also, if you add a |\pause| command before the |itemize|, you would also have to update the overlay specifications.
707
708 \beamer\ offers a special syntax to make creating lists as the one above more ``robust.'' You can replace it by the following list of \emph{incremental overlay specifications}:
709 \begin{verbatim}
710 \begin{itemize}
711 \item<+-> Apple
712 \item<+-> Peach
713 \item<+-> Plum
714 \item<+-> Orange
715 \end{itemize}
716 \end{verbatim}
717
718 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).
719
720 In the above example, the first specification is replaced by |<1->|. Then the second is replaced by |<2->| and so forth. We can now easily insert new entries, without having to change anything else. We might also write the following:
721 \begin{verbatim}
722 \begin{itemize}
723 \item<+-| alert@+> Apple
724 \item<+-| alert@+> Peach
725 \item<+-| alert@+> Plum
726 \item<+-| alert@+> Orange
727 \end{itemize}
728 \end{verbatim}
729
730 This will alert the current item when it is uncovered. For example, the first specification \verb/<+-| alert@+>/ is replaced by \verb/<1-| alert@1>/, the second is replaced by \verb/<2-| alert@2>/, and so on. Since the |itemize| environment also allows you to specify a default overlay specification, see the documentation of that environment, the above example can be written even more economically as follows:
731 \begin{verbatim}
732 \begin{itemize}[<+-| alert@+>]
733 \item Apple
734 \item Peach
735 \item Plum
736 \item Orange
737 \end{itemize}
738 \end{verbatim}
739
740 The |\pause| command also updates the counter |beamerpauses|. You can change this counter yourself using the normal \LaTeX\ commands |\setcounter| or |\addtocounter|.
741
742 Any occurrence of a |+|-sign may be followed by an
743 \emph{offset} in round brackets. This offset will
744 be added to the value of |beamerpauses|. Thus, if
745 |beamerpauses| is 2, then |<+(1)->| expands to
746 |<3->| and |<+(-1)-+>| expands to |<1-2>|. For example
747 \begin{verbatim}
748 \begin{frame}
749 \frametitle{Method 1}
750 \begin{itemize}
751 \item<2-> Apple
752 \item<3-> Peach
753 \item<4-> Plum
754 \item<5-> Orange
755 \end{itemize}
756 \end{verbatim}
757 and
758 \begin{verbatim}
759 \begin{itemize}[<+(1)->]
760 \item Apple
761 \item Peach
762 \item Plum
763 \item Orange
764 \end{itemize}
765 \end{verbatim}
766 are equivalent.
767
768 There is another special sign you can use in an overlay specification that behaves similarly to the |+|-sign: a dot. When you write |<.->|, a similar thing as in |<+->| happens \emph{except} that the counter |beamerpauses| is \emph{not} incremented and \emph{except} that you get the value of |beamerpauses| decreased by one. Thus a dot, possibly followed by an offset, just expands to the current value of the counter |beamerpauses| minus one, possibly offset. This dot notation can be useful in case like the following:
769 \begin{verbatim}
770 \begin{itemize}[<+->]
771 \item Apple
772 \item<.-> Peach
773 \item Plum
774 \item Orange
775 \end{itemize}
776 \end{verbatim}
777
778 In the example, the second item is shown at the same time as the first one since it does not update the counter.
779
780 In the following example, each time an item is uncovered, the specified text is alerted. When the next item is uncovered, this altering ends.
781 \begin{verbatim}
782 \begin{itemize}[<+->]
783 \item This is \alert<.>{important}.
784 \item We want to \alert<.>{highlight} this and \alert<.>{this}.
785 \item What is the \alert<.>{matrix}?
786 \end{itemize}
787 \end{verbatim}
788
789 The expansions of the |+|-sign and the |.|-sign are no less than zero. This prevents errors when encountering large negative offsets, for example |<+(-7)->| is expanded to |<0->| rather than |<-6->|.