beamer / doc / beamerug-overlays.tex

{This text is shown only in article mode.} \end{verbatim} 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 || means on all slides in |beamer| mode and also on all slides in all other modes, since nothing special is specified for them,'' whereas || means on all slides in |beamer| mode and not on any other slide.'' Mode specifications can also be used outside frames as in the following examples: \begin{verbatim} \section{This section exists only in the presentation modes} \section
{This section exists only in the article mode} \end{verbatim} Presentation modes include |beamer|, |trans| and |handout|. You can also mix pure mode specifications and overlay specifications, although this can get confusing: \begin{verbatim} \only{Riddle} \end{verbatim} 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// differs from || and from ||.) 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 || means on slide 2'' and || also means on slide 2''. To get a slide that is typeset in |beamer| mode, but not in |second| mode, you can use, ||. \subsubsection{Action Specifications} \label{section-action-specifications} This section also introduces a rather advanced concept. You may also wish to skip it on first reading. Some overlay specification-aware commands cannot only handle 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: \begin{verbatim} \item<3-| alert@3> Shown from slide 3 on, alerted on slide 3. \end{verbatim} 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. 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. By default, the following actions are available: \begin{itemize} \item \declare{|alert|} alters the item or block. \item \declare{|uncover|} uncovers the item or block (this is the default, if no action is specified). \item \declare{|only|} causes the whole item or block to be inserted only on the specified slides. \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|). \item \declare{|invisible|} causes the text to become invisible on the specified slides. \end{itemize} 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. 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: \begin{verbatim} \newenvironment{checkenv}{\only{\setbeamertemplate{itemize item}{X}}}{} \end{verbatim} You can then write \begin{verbatim} \item Text. \end{verbatim} 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. The whole action mechanism is based on the following environment: \begin{environment}{{actionenv}\sarg{action specification}} 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}. 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. \example \begin{verbatim} \begin{frame} \begin{actionenv}<2-| alert@3-4,6> This text is shown the same way as the text below. \end{actionenv} \begin{uncoverenv}<2-> \begin{alertenv}<3-4,6> This text is shown the same way as the text above. \end{alertenv} \end{uncoverenv} \end{frame} \end{verbatim} \end{environment} \begin{command}{\action\sarg{action specification}\marg{text}} This has the same effect as putting \meta{text} in an |actionenv|. \example |\action{Could also have used \alert<2>{}.}| \end{command} \begin{command}{\beamerdefaultoverlayspecification\marg{default overlay specification}} 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}. 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. 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. \example |\beamerdefaultoverlayspecification{<+->}| \example |\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.) \end{command} \subsubsection{Incremental Specifications} \label{section-incremental} 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. Often you want to have overlay specifications that follow a pattern similar to the following: \begin{verbatim} \begin{itemize} \item<1-> Apple \item<2-> Peach \item<3-> Plum \item<4-> Orange \end{itemize} \end{verbatim} 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. \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}: \begin{verbatim} \begin{itemize} \item<+-> Apple \item<+-> Peach \item<+-> Plum \item<+-> Orange \end{itemize} \end{verbatim} 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). 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. We might also write the following: \begin{verbatim} \begin{itemize} \item<+-| alert@+> Apple \item<+-| alert@+> Peach \item<+-| alert@+> Plum \item<+-| alert@+> Orange \end{itemize} \end{verbatim} 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: \begin{verbatim} \begin{itemize}[<+-| alert@+>] \item Apple \item Peach \item Plum \item Orange \end{itemize} \end{verbatim} The |\pause| command also updates the counter |beamerpauses|. You can change this counter yourself using the normal \LaTeX\ commands |\setcounter| or |\addtocounter|. Any occurence of a |+|-sign may be followed by an \emph{offset} in round brackets. This offset will be added to the value of |beamerpauses|. Thus, if |beamerpauses| is 2, then |<+(1)->| expands to |<3->| and |<+(-1)-+>| expands to |<1-2>|. For example \begin{verbatim} \begin{frame} \frametitle{Method 1} \begin{itemize} \item<2-> Apple \item<3-> Peach \item<4-> Plum \item<5-> Orange \end{itemize} \end{verbatim} and \begin{verbatim} \begin{itemize}[<+(1)->] \item Apple \item Peach \item Plum \item Orange \end{itemize} \end{verbatim} are equivalent. 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: \begin{verbatim} \begin{itemize}[<+->] \item Apple \item<.-> Peach \item Plum \item Orange \end{itemize} \end{verbatim} In the example, the second item is shown at the same time as the first one since it does not update the counter. In the following example, each time an item is uncovered, the specified text is alerted. When the next item is uncovered, this altering ends. \begin{verbatim} \begin{itemize}[<+->] \item This is \alert<.>{important}. \item We want to \alert<.>{highlight} this and \alert<.>{this}. \item What is the \alert<.>{matrix}? \end{itemize} \end{verbatim}