10. Overlay specifications for mathematical environments

Most environments can be equipped with overlay specifications, which makes the whole environment uncover only on the specified slides. You can, for example, show mathematical results sequentially, here is an example:

% Overlay specifications \alt command

% Theme choice:


\begin{frame}{Overlay specifications Math environment}
    When something is repeated more than three times, we say it is spam

    An example of spam is: eggs, eggs, eggs

    I don’t like spam!

    This proof is shown after the corollary.

    Spam is considered something bad


Compiling this code yields:

For each of the basic commands \only, \alt, \visible, \uncover and \invisible there exist “environment versions” onlyenv, altenv, visibleenv, uncoverenv and invisibleenv. The environments do exactly the same as the commands, except for a couple of cases.

11. Overlay area environment

When we talk about changing dynamically elements of the frame, we mean that in a given area different elements may be shown in every slide. For example, you can dynamically change text using the \only command like this

% Changing text dynamically
\only<1>{This text is shown on the first slide.}
\only<2>{And replaced by this one on the second.}
\only<3->{And finally set to this text for the rest of the slides.}

The problem with this approach is that the height of the lines may not be consistent from slide to slide, making undesired and distracting moving effects. When the text is multiple lines long, the effect becomes much more severe.

Beamer has a couple of environments that prevent this undesired effect. Here is an example:

% Overlay area environment
\begin{overlayarea}{area width}{area height}
% Your content here

Everything inside this environment will be placed in a rectangular area of the specified size, which will remain the same along all the slides of the frame, regardless of the contents it contains.

12. Changing images dynamically

You can also change images dynamically within a frame. In order to do this, Beamer makes the \includegraphics command overlay specification-aware. For example, you can show the images
1.png, 2.png and 3.png on slides 1, 2 and 3 using the following code:

% Changing images dynamically
\begin{frame}{Show three images sequentially.}

Maybe you want to show each image while keeping the ones that appeared before (for instance, when you are showing different steps of a process). In that case, you could simply change the overlay specifications as follows:

% Changing images dynamically
\begin{frame}{Show three images sequentially}

which will make the images appear one next to each other, if there is enough room for them.


This has been quite a long tutorial. Since I find creating overlays a powerful tool for your presentations, I’m sure the tutorial was worth your time. You can always come back to look for the things you missed, and use it as a reference

Next Lesson: 11 Insert a GIF into LaTeX Beamer — Short guide