-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

LaTeX Cookbook
By :

At a conference or at a seminar, speakers often use a projector or a screen for presenting written information in addition to what they are addressing. Such a presentation document requires a specific kind of layout and features.
In our recipe, we will use the beamer
class, which has been designed specifically for this purpose. It provides the following features:
We will start off with a sample presentation document, which we can extend. Follow the given steps:
beamer
document class:\documentclass{beamer}
Warsaw
:\usetheme{Warsaw}
\begin{document}
\title{Talk on the Subject} \subtitle{What this is about} \author{Author Name} \institute{University of X} \date{June 24, 2015}
frame
environment. The first one will contain the title page:\begin{frame} \titlepage \end{frame}
Outline
. Add the option pausesections
, so the table of contents will be shown stepwise, section by section:\begin{frame}{Outline} \tableofcontents[pausesections] \end{frame}
\section{Introduction} \subsection{A subsection}
frame
environment, including lists, which are visually better than normal text in a presentation:\begin{frame}{Very Informative Title} \begin{itemize} \item First thing to say. \item There is more. \item Another short point. \end{itemize} \end{frame}
\begin{frame}{Another Title With Uppercased Words} Text \begin{alertblock}{A highlighted block} Some important information put into a block. \end{alertblock} \end{frame}
\alert
command. Finally, end the document:\subsection{Another subsection} \begin{frame}{Informative Title} \begin{exampleblock}{An example} An example within a block. \end{exampleblock} Explanation follows. \end{frame} \section{Summary} \begin{frame}{Summary} \begin{itemize} \item Our \alert{main point} \item The \alert{second main point} \end{itemize} \vfill \begin{block}{Outlook} Further ideas here. \end{block} \end{frame} \end{document}
We loaded the beamer
class and chose the theme with the name Warsaw
. You can easily replace it with another theme's name, compile it, and cycle through the themes until you find the best one for your occasion. By default, the following themes are installed:
AnnArbor
Antibes
Bergen
Berkeley
Berlin
Boadilla
boxes
CambridgeUS
Copenhagen
Darmstadt
default
Dresden
EastLansing
Frankfurt
Goettingen
Hannover
Ilmenau
JuanLesPins
Luebeck
Madrid
Malmoe
Marburg
Montpellier
PaloAlto
Pittsburgh
Rochester
Singapore
Szeged
Warsaw
You can see these themes in the gallery at http://latex-beamer.net. We specified the title, subtitle, author, and date of the seminar, which is then printed by \titlepage
. We used a frame
environment, which we have to use for each slide.
The next frame contains the table of contents. We provided the frame title Outline
as an argument to the frame in curly braces. For the \tableofcontents
command, we added the pausesections
option. As a result of doing this, section titles are printed one-by-one with a pause in between. This gives us the opportunity to explain what the audience will hear before they read further.
Here, we used the \section
and \subsection
commands just like in a normal LaTeX document. The heading is not directly printed. The sections and subsections are printed in the frame margin with the current position highlighted.
To get a bulleted list, we used an itemize
environment just as we would in a normal LaTeX document. The environments enumerate
for numbered lists and description
for descriptive lists also work in the beamer
frames.
To highlight information, we used the so-called block
environments. Besides the standard block
environment, we can use the exampleblock
and alertblock
commands to get a different style or color. The chosen theme determines the appearance of those blocks.
The \alert
command is used to emphasize more distinctly, as seen in the last frame.
Now, you have the template and tools to create your presentation.
Consider the following while designing a presentation:
The beamer
package has unique capabilities and an extraordinary design. We will explore it in the following pages.
Besides the title page, the title of the presentation and the author's name are additionally printed at the bottom of each frame. The exact position depends upon the chosen theme.
However, for long titles or names, the space might be insufficient. You can provide short versions to be used in such places, for example, by specifying the following commands:
\title[Short title]{Long Informative Title} \author[Shortened name]{Author's Complete Name} \date[2015/06/24]{Conference on X at Y, June 24, 2015}
The same is possible for the \institute
and \subtitle
commands, if you would use these commands in your presentation.
You can provide short names for sections and subsections in exactly the same way, so they would better fit into their field within the frame margin; just use the optional argument in square brackets. The \part
and \subsubsection
commands work similarly, they can get a short name in square brackets as well.
Showing a complete slide at once may be a bit distracting. People may read ahead instead of listening to you. You can take them by the hand by displaying the content step by step.
The simplest way is to insert a \pause
command. It can go between anything such as text, graphics, and blocks. It also works between two \item
commands in a bulleted list; however, consider pausing between whole lists instead of items. Simply use it like we will do in the following line of code:
Text\pause more text\pause\includegraphics{filename}
Such a frame is then layered; that is, divided into overlays. They are internally numbered. If you would like to show something at a certain overlay, you can tell the beamer
package when to uncover it:
\uncover<3->{Surprise!}
This shows your text on slide 3 of the current frame; and it will stay on the following slides in that frame. Omit the dash for restricting it to only slide 3. You can also list multiple slides, such as <3,5>
, give ranges such as <3-5>
, and mix the two, as in <3,5->
.
This syntax works with overlay-specification-aware commands. Among them, there are \item
, \includegraphics
, and even \renewcommand
, so you can use them with an overlay specification such as the following:
\includegraphics<3->{filename}
Overlays should not be too fancy. A presentation needs a linear structure; complicated overlays may be handy for showing and hiding annotation to an object, while you explain that.
Refer to the beamer
manual for more information on using overlays. You can open that manual via texdoc
beamer
in Command Prompt, or online at http://texdoc.net/pkg/beamer.
You can arrange text and images in multiple columns on a frame. This is especially handy for images with explanatory text. Let's take a look at a sample:
\begin{frame} Some text which can use whole frame width \begin{columns}[t] \begin{column}{0.45\textwidth} Sample text in\\ two lines \end{column} \begin{column}[T]{0.45\textwidth} \includegraphics[width=3cm]{filename} \end{column} \end{columns} \end{frame}
We started the multicolumn area using the column
environment. You can specify alignment options t
, b
, or c
for top, bottom, or centered alignment of the column. Centered is the default. While t
aligns at the baseline of the first line, which is common in LaTeX, there's a handy additional option, T
, which aligns at the very top.
Each column is created by the column
environment. The column width is given as an argument. It understands the same positioning options, so you can override what you set in the surrounding columns environment. We added the [T]
option here, because an image has its baseline at its bottom, and we want to change it to the very top.
You can tell the beamer
package to give an outline at the beginning of each section by specifying the following code:
\AtBeginSection{ \begin{frame}{Outline} \tableofcontents[currentsection] \end{frame}}
You can also use the \AtBeginSection
command to insert different lines of code. If something should happen in case of a starred \section*
too, you can insert the corresponding code within an optional argument in square brackets after \AtBeginSection
.
By default, every slide shows small navigation symbols; here, at the bottom of a frame. If you don't need them, you can save that space and reduce the distraction by specifying the following line of code:
\setbeamertemplate{navigation symbols}{}
The default font set with the beamer
package is Computer Modern. You can change it to other fonts as discussed in Chapter 3, Adjusting Fonts.
The default font is sans serif. Even the math formulas are sans serif. With a low projector resolution, or at some distance, this can be more readable than with a serif font.
However, if you would like to change to a serif font, you can load the corresponding font theme in the preamble:
\usefonttheme{serif}
Another available font theme is professionalfonts
, which actually doesn't change fonts, but simply uses the set you specify separately. Furthermore, there are structurebold
, structureitalicserif
, and structuresmallcapsserif
, which change the font in the structure, that is, in headlines, footlines, and sidebars, to such a shape combination.
The quickest way to change colors is by loading a theme with a thoughtful selection of colors for the various structure elements. Use a single command as follows:
\usecolortheme{dolphin}
There are outer color themes, providing a color set for headlines, footlines, and sidebars. The author of the beamer
package gave them sea animal names: dolphin
, whale
, and seahorse
. Then, there are inner color themes for elements, such as color blocks, with names of flowers: lily
, orchid
, and rose
. Combine inner and outer color themes as you like.
Finally, there are complete themes covering all structure aspects: albatross
, beaver
, beetle
, crane
, dove
, fly
, monarca
, seagull
, spruce
, and wolverine
. They are named after flying animals, except wolverine
, beaver
and spruce
, which are external additions.
A lot of names, you may go through them using the \usecolortheme
command to find the color set you like the most.
With some labor, you can create your very own theme. The extensive beamer
manual will guide you. However, you may save a lot of time; beamer is very popular among academic users, who already use LaTeX for their papers, so you can find a lot of themes prepared for universities and institutes, but also designed by various beamer users.
You can find an overview of beamer
themes at http://latex-beamer.net.
Explore the gallery there, download the theme you like, add your logo, and tweak it. Instructions for using the themes that are available on the website.
You can give your audience a printed version of the slides. Just create a version of your document with the handout
option, so no overlays will be used:
\documentclass[handout]{beamer}
Slides are commonly small, so it's good to print several slides on a single page:
\usepackage{pgfpages} \pgfpagesuselayout{4 on 1}[a4paper, border shrink=5mm,landscape]
This prints four slides on an A4 page in landscape. You can get bigger prints, two slides on each page, in portrait mode, by specifying the following line of code:
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
We used the pgfpages
option, a utility package that comes with the pgf
package.
Change the font size
Change margin width
Change background colour