\usetheme{Madrid}, \usetheme{Warsaw}, \usetheme{Singapore} — beamer, the LaTeX class for presentation slides, ships 27 current presentation themes, and every single one is named after a city. The author explains why in the manual: he ran out of ideas for names, and the cities are ones where he or a co-author attended a conference or workshop. That offhandedness is characteristic of the class as a whole. Writing beamer is almost exactly like writing any other LaTeX document, with a single difference that changes everything: the unit is the frame, not the page. This page starts from that one fact and works outward — frames, overlays, themes, and why a verbatim environment breaks a slide the moment you add one.
How beamer differs from a normal document class
From the moment you write \documentclass{beamer}, the tools that push pages around stop working. Put \newpage inside a frame and it produces no error, no warning — it is simply ignored; try it and the two paragraphs on either side of it come out side by side on a single slide. The reason is straightforward: in beamer the page breaks are decided by the boundaries of frame, not by the author. By the same logic \section{...} prints nothing in the body — it only registers with the table of contents and the navigation. And prose written outside any \begin{frame} is not an error either: it is typeset as a bare page with no theme on it. That is almost always the cause of “there is a strange page in the middle of my deck”.
The other departure from a paper document is the dimensions: beamer sets a screen, not a sheet. The default is 4:3, spelled out in beamer.cls as \beamer@paperwidth{12.80cm} and \beamer@paperheight{9.60cm} — that is 128 mm × 96 mm. A class option changes the ratio: \documentclass[aspectratio=169]{beamer} gives 16:9 at 160 mm × 90 mm. The version in TeX Live 2024 has explicit entries for eight values — 1610, 169, 149, 54, 43, 32, 141 and 2013. What is interesting is what it does with anything else: hand it a number that is not in the list and beamer pins the height at 9.60 cm and computes the ratio by splitting the digits. Write aspectratio=21 and you get a genuine 2:1 slide, 19.2 cm wide. The body font size is set the usual way, as in \documentclass[11pt]{beamer}; the default is 11pt.
The frame environment: one slide is not one page
The heart of beamer is the frame environment. Everything from \begin{frame} to \end{frame} is one logical screen, and inside it go your bullets, figures and equations. Give it a heading with \frametitle{...}, or pass it as an argument: \begin{frame}{Title}. The crucial point is that one frame is not necessarily one page. With the overlays of the next section, a single frame produces several PDF pages that read as a stepwise reveal when you page through them. A frame is the logical screen; a PDF page is one still of it — beamer's own documentation keeps the two words apart, calling the first a frame and the second a slide.
frame takes options in brackets. The one you will reach for most is [allowframebreaks], for when the content overflows vertically. beamer then splits the frame across as many pages as it needs and — a nice touch — appends a roman numeral to the frame title: pour in a list of twenty-two items and the first page is headed “Long I” and the second “Long II”. Others worth knowing are [t], [c] and [b] to align the content top, centre or bottom; [plain], which strips the theme's furniture so a figure can fill the screen; [label=...] so the frame can be recalled later with \againframe; and [noframenumbering] to keep a frame out of the count. The [fragile] of the next section goes in the same place.
Title metadata is declared in the preamble, exactly as in article. Write \title{...}, \author{...}, \institute{...} and \date{...}, then put \titlepage inside one frame in the body to typeset the title slide (\maketitle gives the same result). For a longer talk, dividing the material with \section{...} feeds the structure into the navigation along the top of each slide. Once the sections are declared, \tableofcontents inside a frame produces a contents slide, and \tableofcontents[currentsection] highlights only the section you are in. To have such a frame inserted automatically at the head of every section, wire it up with \AtBeginSection[]{...} in the preamble.
Overlays: the difference between \pause and <2->
Revealing content a piece at a time is what overlays do, and there are two ways in. \pause just sits partway through a frame and pushes everything after it onto the next slide — easy, but it can only ever build up one step at a time in source order. The other is the overlay specification, the angle-bracket <...> you attach directly after a command. \item<1-> means “from slide 1 onward”, \item<2> means “on slide 2 only”, \item<2-> means “from slide 2 on”. You can list ranges and gaps together, as in <-2,4-5,7>. Compile one and it behaves exactly as written: the item marked \item<3> appears on the third slide, \only<2>{...} shows up on the second and nowhere else, and \uncover<3->{...} becomes visible from the third.
| Command | Behaviour | Space while hidden |
|---|---|---|
\pause | Pushes what follows to the next slide | Content is added in turn, so the question does not arise |
\uncover<2->{...} | Becomes visible on the given slides | Always reserved, so the layout never jumps |
\onslide<2->{...} | Shown on the given slides, hidden otherwise | Always reserved |
\only<2>{...} | Emits output only on the given slides | Not reserved, so later content moves up |
\alert<2>{...} | Switches to the alert colour on the given slides | Always visible, so always reserved |
[<+->] | On a list environment, steps through every item automatically | Behaves like \uncover |
The third column is where this table earns its keep. \uncover and \onslide reserve the space even while hidden, so nothing around them moves as items appear. \only inserts and removes the output itself, so the hidden space is reclaimed and everything after it shifts. For swapping out part of a formula that is exactly what you want; for simply walking down a bullet list it is a trap, and \uncover or [<+->] is the safer choice. The same overlay syntax attaches to \textbf and \textcolor as well as to \alert, so “bold on this slide only” needs no new grammar.
% the blunt instrument: everything after \pause moves to the next slide
\begin{frame}{Results}
\begin{itemize}
\item First point
\pause
\item Second point
\end{itemize}
\end{frame}
% overlay specifications: say exactly which slides each piece belongs to
\begin{frame}{Results}
\begin{itemize}
\item<1-> Always there
\item<2-> From slide two
\item<3> Slide three only
\end{itemize}
\only<2>{Shown on slide 2, and takes no space otherwise}
\uncover<3->{Space is reserved from the start, ink appears on slide 3}
\end{frame}
% the same stepwise reveal, without numbering each item by hand
\begin{frame}{Results}
\begin{itemize}[<+->]
\item Observation
\item Interpretation
\item Limitation
\end{itemize}
\end{frame}Themes: cities, flying animals, flowers and sea creatures
There are five kinds of theme, and the name tells you which kind you are looking at. The city names from the opening — Madrid, Warsaw, Berlin, Singapore and the rest — are presentation themes, the ones that set everything at once. The colour themes carry the idea further, and the manual gives the game away itself. Flying animals (albatross, beetle, crane) are the “complete” colour themes, which specify every colour themselves. Flowers (lily, orchid, rose) are inner colour themes, changing only the colours of inner elements such as blocks. Sea animals (whale, dolphin, seahorse) are outer colour themes, governing the palette of the headline, footline and sidebar. So the moment you write \usecolortheme{whale}, the name has already told you it only touches the furniture around the edge.
| Command | What it sets | Example |
|---|---|---|
\usetheme | Layout, navigation and colours, all at once | \usetheme{Madrid} (a city) |
\usecolortheme | Swaps the palette only | \usecolortheme{seahorse} (sea animal = outer) |
\usefonttheme | Typefaces for headings and body | \usefonttheme{serif}, \usefonttheme{professionalfonts} |
\useinnertheme | Styling of inner elements (bullets, block shapes) | \useinnertheme{rounded} |
\useoutertheme | Styling of the frame furniture (headline, footline, sidebar) | \useoutertheme{infolines} |
In practice the quick route is to pick one \usetheme{...} and then override just the parts you dislike with the four commands below it. Choose by purpose: Madrid or Boadilla when a navigation bar would only get in the way, Frankfurt or Warsaw when you want the audience to see where they are. For a more contemporary look, metropolis (\usetheme{metropolis}) is the usual answer — not part of beamer itself, but shipped in TeX Live as a separate package. One warning: cycling through themes is a famously good way to lose an afternoon. The audience is looking at your content, not your palette, so settle on one early and go back to writing.
block and columns: framing content and splitting the slide
To set content off in a framed box, use the block environment: \begin{block}{Title}…\end{block} produces a titled box coloured to match the theme. The attention-seeking alertblock and the exampleblock work the same way, and theorem and definition environments are available directly for theorems and definitions (beamer loads amsthm for you). To split a slide left and right, put \column{width} entries inside the columns environment — the standard move for setting a figure beside its explanation.
\begin{frame}{Comparison}
\begin{columns}
\column{0.5\textwidth}
\begin{block}{Before}
The old estimate.
\end{block}
\column{0.5\textwidth}
\begin{alertblock}{After}
The corrected one.
\end{alertblock}
\end{columns}
\end{frame}Why a verbatim environment breaks a frame, and what [fragile] does
Put a verbatim environment or an lstlisting from the listings package inside a frame and the compile stops unless you have written \begin{frame}[fragile]. The awkward part is how it stops. Tried on TeX Live 2024, beamer points not at a line number but at the whole file, and says: Runaway argument?, then ! File ended while scanning use of \@xverbatim., then I suspect you have forgotten a }, causing me to read past where you wanted me to stop. and finally ! Emergency stop. You get the name of an internal macro you never typed, plus a confident diagnosis that you left a brace open. No brace is open. Follow that advice and you will spend a long time counting braces in a file that has nothing wrong with its braces.
The real cause is not braces but the order in which things are read. beamer reads the whole body of a frame as an argument first, then typesets it once per overlay slide. But verbatim works by changing how characters are interpreted as they are read, which is too late for a body that has already been swallowed. That is why the error opens with Runaway argument? — the accident happens precisely while the body is being read as an argument. [fragile] sends beamer down a different path. In the user guide's own words, the frame contents are written out to an external file and then read back. Compile one and you can see it happen: a new file with a .vrb extension appears in the working directory, containing the body of the frame verbatim.
Routing the body through a file creates a second rule. As the user guide states explicitly, in a [fragile] frame \end{frame} must stand alone on its line (leading whitespace aside). beamer is scanning for the literal string at the start of a line to know where to stop writing, so folding it up as \end{verbatim} \end{frame} fails the same way, this time naming a different internal macro: ! File ended while scanning use of \next. One more point: overlay commands like \alert<2>{...} do not work inside verbatim, because printing characters exactly as given is the whole job of verbatim. When you need to highlight part of a listing, use beamer's own semiverbatim environment instead — almost identical to verbatim except that \, { and } survive as commands, so an \alert<2>{...} can be slipped in.
\begin{frame}[fragile]{An algorithm} % [fragile] -> body goes via a .vrb file
\begin{verbatim}
int main(void) { return 0; }
\end{verbatim}
\end{frame} % must be alone on its own line
% to highlight part of a listing, use semiverbatim rather than verbatim
\begin{frame}[fragile]{Highlighted}
\begin{semiverbatim}
for (int i = 2; i < 100; i++)
\alert<2>{if (is_prime[i])}
\end{semiverbatim}
\end{frame}The smallest beamer document that compiles
Here is the minimum that gives you a theme, a title slide and a stepwise list. The preamble declares the theme and the title metadata; the body puts \titlepage in the first frame and a [<+->] list in the second. There are two frames, but the overlays expand the PDF to four pages. For Japanese slides, add engine-appropriate Japanese support to the preamble — loading luatexja under LuaLaTeX, for instance.
\documentclass[aspectratio=169,11pt]{beamer}
\usetheme{Madrid}
\usecolortheme{seahorse}
\title{My Talk}
\author{Ada Lovelace}
\institute{Analytical Engine Lab}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{Overview}
\begin{itemize}[<+->]
\item Background
\item Method
\item Results
\end{itemize}
\end{frame}
\end{document}A workflow for an actual talk
beamer is not a tool for slicing a paper into pieces. Divide the talk into a few movements — problem, method, results, conclusion — and put exactly one claim in each frame. Rather than pasting long paragraphs from the manuscript, compress them into figures, equations and short bullets, and add \pause or <2-> only where a staged reveal genuinely earns its place. Overlays are a way of controlling the order of an explanation, not decoration.
- Fix the aspect ratio first — if you know the projector, lock in
aspectratio=169or43before you design anything. Changing it later shifts every figure you have placed. - Density per slide — three to five bullets. When it overflows, splitting the frame usually reads better than escaping into
[allowframebreaks]. - Code and logs — always give
[fragile]to frames containingverbatim,lstlistingorminted, and keep\end{frame}on a line of its own. - Frames where a figure should dominate —
[plain]strips the theme's furniture so the image can use the whole screen. - The PDF you hand out — a talk deck and a handout are different documents. Collapsing the overlays with
handoutmode, and writing speaker notes, are covered on the Handouts page.