# Math-Linux.com

Knowledge base dedicated to Linux and applied mathematics.

Home > Latex > How to make a presentation with Latex - Introduction to Beamer

## How to make a presentation with Latex - Introduction to Beamer

We shall see in this article how to make a presentation with LaTeX, using the powerful class Beamer. If you want to make an outstanding "stressfree" presentation and bring your ideas or your work under a whole new light, let’s get started!!!

### Installing the Beamer class

You will first need to install the package Beamer.
Under Debian or Ubuntu, you can type the following command:

# apt-get install latex-beamer

Once the latex-class Beamer is installed, you are definitely ready to stat your first presentation!!!

### Basic presentation with Beamer

\documentclass{beamer}
\usepackage[latin1]{inputenc}
\usetheme{Warsaw}
\title[Make a LaTeX presentation using Beamer]{Introduction  to Beamer\\How to make a presentation with LaTeX?}
\institute{Math-linux.com}
\date{Jule 13, 2007}
\begin{document}

\begin{frame}
\titlepage
\end{frame}

\begin{frame}{Introduction}
This is a short introduction to Beamer class.
\end{frame}

\end{document}

A few explanations:

\documentclass{beamer}

means that our document is a Beamer presentation

\usepackage[latin1]{inputenc}

this package enables us to use special letters (with accents, cedillas, etc). You can discard this command when the presentation is in English.

\usetheme{Warsaw}

This is our outer theme (color and background). As you can imagine, there are tons of themes. You can refer to Beamer documentation for more details.

\title[Making a LaTeX presentation with Beamer]{Introduction to Beamer\\How to make a LaTeX presentation?}

this defines the title of the presentation. As you can see, there are two titles:
the first one, between brackets. [Making a LaTeX presentation with Beamer] is a substitute title which appears at the bottom of the page. This is useful especially if the original title is long. Since this is anoption only, if it is not mentioned, then the original title is the one shown in the bottom of the page.
the second one, between braces, is the principal title of the presentation.
The command

\author{Nadir Soualem -- Astozzia}

defines Nadir Soualem and Astozzia (us!) as the authors of the presentation.

\institute{Math-linux.com}

defines where the presentation was held. Finally, we use

\date{July 13, 2007}

as the date.

To define the document, we use the markers

\begin{document}
...
\end{document}

To define a slide of the presentation, we use the markers

\begin{frame}
...
\end{frame}

To define a page title (frame), we mention it as follows

\begin{frame}{Introduction}

Introduction will be the title of the page.
To define the first page, which contains details such as the title, the author, the date, etc - we use a frame in which we include the \titlepage command

\begin{frame}
\titlepage
\end{frame}

To define a frame containing the layout of the presentation, we proceed as follows:

\AtBeginSubsection[]
{
\begin{frame}<beamer>
\frametitle{Layout}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}

The layout is therefore mentioned at every section and subsection.
You should insert \section and \subsection throughout the presentation and out of the frames:

\section{Name_of_the_section}
\begin{frame}
...
\end{frame}
...
\section{Name_of_the_section}
\subsection{Name_of_the_subsection}
\begin{frame}
...
\end{frame}

### Animations — Overlays

A good presentation is one that is dynamic and attracts the audience’s interest. Generally, we resort to a dynamic type of presentations. Alternatively stated, when we speak, we simultaneously show significant points of the talk, or hide others, or keep just the important ones.
We shall see in this section how animations function in Beamer.

### Item-by-item list view: the \pause command

In order to view several items of a list on the same slide, we type the following commands inside a frame:

\begin{itemize}
\pause \item Beamer is a wonderful class
\pause \item One can make animations
\pause \item One uses the\textbf{pause} command, for example
\pause \item in order to bring in important ideas
\end{itemize}

We will thus see the items of our list, one by one.

### Item-by-item list view: the \item<n-> command

An alternative way to visualize the elements of a list item by item is to use the \item<n-> command, where n is a natural number referring to the slide, beginning from which the item appears.

\begin{itemize}
\item<2-> appears from slide 2 on
\item<3-> appears from slide 3 on
\item<4-> appears from slide 4 on
\item<5-> appears from slide 5 on
\end{itemize}

### List item interval and isolated items: the \item<n-m> and \item<p> commands

An example is worth a long speech:

\begin{itemize}
\item<2-> appears from slide 2 on
\item<2-4> appears from slide 2 to slide 4
\item<4> appears on slide 4
\item<3-> appears from slide 3 on
\end{itemize}

\item<n-m> means that the list item will appear on slides numbered n to m, whereas \item<p> means that the item will appear on slide p.

### Item-by-item long list view: the [<+->] command

Sometimes the lists you want to display are long and it is not practical to use the
\item<n-> command. An alternative solution is the use of the [<+->] command

\begin{itemize}[<+->]
\item L
\item A
\item T
\item E
\item X
\end{itemize}

Up to now, we have dealt with lists. We shall now see how to use text and slides.

### Displaying and hiding text in slides: the \uncover<n->, \uncover<n-m> and \uncover<p> commands

\uncover<n-> will display the text from slide n on;
\uncover<n-m> means the text element will appear from slide n to m. Finally, \uncover<p> means that the text will appear on slide p.
Here is a case in point of a frame containing the \uncover command.

\begin{frame}

\uncover<2->
{appear from slide 2 on\\}
\uncover<3-4>
{appears from 3 to slide 4\\}
\uncover<4>{appears on slide 4\\}
\uncover<3->{appears from slide 3 on\\}

\end{frame}

Be careful not to forget the braces after the \uncover command. The syntax is as follows:

\uncover<n>{...}
\uncover<n-m>{...}
\uncover<p>{...}

### Displaying and hiding text in slides: the \only<n->, \only<n-m> and \only<p> commands

\only works like\uncover with the exception that the \only command is not as "cumbersome" on slides. Here is an example:

\begin{frame}

\only<2->
{appear from slide 2 on\\}
\only<3-4>
{appears from 3 to slide 4\}
\only<4>{appear on slide 4\\}
\only<3->{appear from slide 2 on\\}

\end{frame}

Here is an other example to better grasp the difference between \only and \uncover

\begin{frame}

\begin{itemize}
\item Language used by Beamer: L\uncover<2->{A}TEX
\item Language used by Beamer: L\only<2->{A}TEX
\end{itemize}

\end{frame}

### Hide text in slides: the \invisible<n> commands

\invisible<n> makes text invisible on slide n

\begin{frame}

\invisible<2>{This text will be invisible on slide 2, but not on others slides}\\
This text is always visible\\
\uncover<1->{Beamer} \uncover<2->{is}  \uncover<3->{super} \uncover<4->{powerful}

\end{frame}

### Another alternative: the \alt<n>{...}{...} commands

As an alternative, one can use the \alt{...}{...} command on a slide. The first argument is the value on slide n. The second is for values other than n. Here is an example:

\alt<3>{I am on slide 3\\}{I am not on slide 3\\}
\only<2->
{appears from slide 2 on\\}
\only<3-4>
{appears from slide 3 to slide 4\\}
\only<4>{appears on slide 4\\}
\only<3->{appears from slide 3 on\\}

### Highlighting text in red: the \alert<n>{...} command

To highlight text in red on slide n, we use the \alert<n>{...} command.

\alert<1>{This text} \alert<2>{is} \alert<3>{red}

### Successively highlighting list items in red: the <+-| alert@+> command

\begin{itemize}
\item <+-| alert@+> Robert De Niro
\item <+-| alert@+> Brian De Palma
\end{itemize}

### Using colors in a text on a slide: the \color<n->{...}{...}, \color<n-m>{...}{...} and\color<p>{...}{...} commands

The first argument is the red, green, yellow, blue, etc ... The second is the text to be colored

Some colors ...\\
\color<2>{green}{Green color\\}
Great !!!

To define internal links, we should add the following package in the preamble

\usepackage{hyperref}

Then, we should define a label pointing on the frame:

\begin{frame}[label=MY_LABEL]
The link will point to this frame
\end{frame}

you define MY_LABEL as you please !
Finally, on the frame where the link is to be created, we proceed as follows:

\hyperlink{MY_LABEL}{\beamergotobutton{Refer to this page}}

There we are! We can see a button Refer to this page pointing to the frame labeled MY_LABEL.

Thus, the first argument of \hyperlink{...}{\beamergotobutton{...}} is the name of the label to be pointed at and \beamergotobutton{...} has the name of the button as an argument.

### Defining blocks inside frames

For important stuff, we define blocks as follows:

\begin{block}{Block title}
This is a block in blue
\end{block}

This is a block in red

\begin{exampleblock}{Example-block title}
This is a block in green
\end{exampleblock}

As clear as onion soup !!!

### Dynamic display of tables: the \pause and \onslide<n-> commands

First off, we should add the package colortbl to the preamble

\usepackage{colortbl}

To display rows dynamically, we shall use the \pause command as follows:

\begin{tabular}{lcccc}
Class & A & B & C & D \\\hline
X     & 1 & 2 & 3 & 4 \pause\\
Y     & 3 & 4 & 5 & 6 \pause\\
Z     &5&6&7&8
\end{tabular}

To display columns dynamically, we shall use the \onslide<n-> command as follows:

\begin{tabular}{lc<{\onslide<2->}c<{\onslide<3->}c<{\onslide<4->}c<{\onslide}c}
Class & A & B & C & D \\
X     & 1 & 2 & 3 & 4 \\
Y     & 3 & 4 & 5 & 6 \\
Z     &5&6&7&8
\end{tabular}

### Writing on several columns: the \begin{columns}...\end{columns} commands

For two columns, we proceed as follows:

\begin{columns}
\begin{column}[l]{5cm}
First column
\end{column}
\begin{column}[r]{5cm}
Second column
\end{column}
\end{columns}

l,r,c refers to the position: left, right, center.
The syntax is as follows:

\begin{columns}
\begin{column}[position]{column width}
...
\end{column}
\begin{column}[position]{column width}
...
\end{column}
\end{columns}

### Inserting a figure in a Beamer presentation

To insert an image or a figure, we proceed as in LaTeX by using the \includegraphics command. Here is an example:

\begin{figure}
\includegraphics[options]{path_to_image}
\end{figure}

In Beamer, we should distinguish between two types of figures:
PS type: .eps, .ps and pspicture type (LaTeX)
General type: .pdf, .png, .jpg, .jpeg
You will need to compile a Beamer-class file.

### Compiling a Beamer presentation

I assume that the your file is called file.tex.. There are ways to compile, depending on the type of figure you inserted. For PS-type figures, we shall use the following commands

$latex file.tex$ latex file.tex
$dvips file.dvi$ ps2pdf file.ps

We shall obtain the file file.pdf.

For general-type figures, we shall use the command

$latex2pdf file.tex$ latex2pdf file.tex

We shall also obtain the file file.pdf.

### Conclusion

It goes without saying that explaining all the possibilities that Beamer offers is way too long. This is why I am referring to this exhaustive documentation documentation.

Have fun !!!