How to create presentations with Beamer

How to create presentations with Beamer

Beamer brings LaTeX's powerful typesetting features and ecosystem to creating slides.

5 people in a meeting watching a presentation
Image credits : 
Vector Open Stock. CC BY-SA 3.0.

Get the newsletter

Join the 85,000 open source advocates who receive our giveaway alerts and article roundups.

Beamer is a LaTeX package for generating presentation slide decks. One of its nicest features is that it can take advantage of LaTeX's powerful typesetting system and all the other packages in its ecosystem. For example, I often use LaTeX's listings package in Beamer presentations that include code.

Starting a presentation

To begin a Beamer document, enter:


As you would with any other LaTeX document, add any packages you want to use. For example, to use the listings package, enter:


Place all content inside the document environment:


Beamer documents are usually a sequence of frame environments. Frames that contain code should be marked fragile:


Begin your frames with a title:

\frametitle{Function to Do Stuff}

Testing your code before you present it

One of the worst feelings in the world is giving a talk and realizing, as you walk through the code, that there is a glaring bug in it—maybe a misspelled keyword or an unclosed brace.

The solution is to test code that is presented. In most presentation environments, this means creating a separate file, writing tests, then copying and pasting.

However, with Beamer, there is a better way. Imagine you have a file named that contains code. You can write tests for the code in a second file, which you call, and can exercise it with, say, pytest. However, most of the lines in lack pedagogic value, like defining helper functions.

To simplify things for your audience, you can import just the lines you want to talk about into the frame in your presentation :


Since you will be talking through those lines (from 8 to 15), you don't need any other content on the slide. Close the frame:


On the next slide, you want to show a usage example for the do_stuff() function you just presented:

\frametitle{Calling Function to Do Stuff}

You use the same file, but this time you show the lines that call the function. Finally, close the document:


Assuming you have an appropriate Python file in, this will produce a short two-slide presentation.

Beamer also supports necessary features such as progressive revelation, showing only one bullet at a time to prevent the audience from being distracted by reading ahead.": \pause inside a list will divide bullets into pages:

\item This will show up on the first slide. \pause
\item This will show up on the
      second slide, as well as the preceding point. \pause
\item Finally, on the third slide,
       all three bullets will show up.

Creating handouts

My favorite feature in Beamer is that you can set it to ignore everything outside a frame with \documentclass[ignorenonframetext]{beamer}. When I prepare a presentation, I leave off the top (where the document class is declared) and auto-generate two versions of it: one with Beamer that ignores all text outside any frame, which I use for my presentation, and one with a header like:


which generates a handout—a PDF that has all the frames and all the text between them.

When a conference organizer asks me to publish my slides, I include the original slide deck as a reference, but the main thing I like people to have is the handout, which has all the explanatory text that I don't want to include on the slide deck itself.

When creating presentation slides, people often wonder whether it's better to optimize their materials for the presentation or for people who want to read them afterward. Fortunately, Beamer provides the best of both worlds.


About the author

Moshe sitting down, head slightly to the side. His t-shirt has Guardians of the Galaxy silhoutes against a background of sound visualization bars.
Moshe Zadka - Moshe has been involved in the Linux community since 1998, helping in Linux "installation parties". He has been programming Python since 1999, and has contributed to the core Python interpreter. Moshe has been a DevOps/SRE since before those terms existed, caring deeply about software reliability, build reproducibility and other such things. He has worked in companies as small as three people and as big as tens of thousands -- usually some place around where software meets system administration...