Taming Beamer

0
7791
Let's learn Beamer

Let's learn Beamer

This article introduces LaTeX and the Beamer extension class, which is ideal for creating professional-quality documents and presentations.

The OpenOffice.org suite, and even the new arrival, LibreOffice, are not mature enough as truly user-friendly professional document-processing tools. An easy solution for this is LaTeX (pronounced ‘Lah-Tech’ or ‘Lay-Tech’), which is extremely popular in academic and scientific communities due to its rich functionality. Scientists prefer to create their research papers using Latex, publishing houses use LaTeX to typeset books, professors use LaTeX to create course handouts and presentations… LaTeX could even be used to design wedding cards and chess boards! Though it is slightly difficult to start learning LaTeX, once learned, the immense power of LaTeX will erase all the difficulties of creating a professional-quality document/presentation on a GNU/Linux system.

For the uninitiated, LaTeX is a highly efficient document preparation system developed by Leslie Lamport. It all started when the legendary author Donald Knuth was writing the second volume of The Art of Computer Programming. The lack of a good type-setting system led him to develop Tex and release it as free software. LaTeX can be thought of as a Tex extension intended for UNIX systems. Like Tex, LaTeX is also free software, released under the LaTeX Project Public License (LPPL).

Why LaTeX

One of the main advantages is that it helps typeset documents beautifully, especially technical documents:
Mathematical formulas can easily be constructed using certain commands.

  1. Being a programming language, a user can easily modify its default behaviour.
  2. The availability of professionally crafted inbuilt layouts make a document really look as if printed.
  3. Documents in PS, PDF formats can be easily generated.

For more information, consider reading the well-written LaTeX Wikibook document.

Classes and packages

Like the Linux mechanism of extending kernel features with modules, LaTeX provides classes and packages for extending behaviour. A class is used to modify a document style. Beamer is one of the most popular LaTeX classes for creating presentations. Prosper is another widely used presentation-making class. Apart from these, LaTeX also provides a default slide class for creating slides.

Packages can be added and used inside a document class. A package is used to provide some additional functionality to an existing document. For example, if we need to insert a picture, we have to include the graphics package. For a document, there can only be a single class, but many packages can be used inside a class. Some commonly used packages are:

  • amsmath — Mathematical formula formatting — \usepackage{amsmath}
  • graphics — Handling imported images — \usepackage{graphicx}
  • fancyhdr — Used to insert custom headers — \usepackage{fancyhdr}
  • makeidx — Used to build an index for a document — \usepackage{makeidx}
  • fontenc: Handling font encodings — \usepackage[encoding]{fontenc}

Classes and packages are loaded with the following statements:

\documentclass [<options>]{<class>}
\usepackage [<options>]{<packages>}

To get a working LaTeX setup, you need a LaTeX distribution (TexLive in GNU/Linux, MikTex in Windows) and an IDE for creating .tex documents. If you already have LaTeX up and running on your system, then skip the next two sections.

How to get a LaTeX distribution

Most major Linux distributions (Debian, Ubuntu or Fedora) have LaTeX in their repositories — the Texlive distribution is the default for most. On Debian-based systems, you can install it with an apt-get install texlive. Or, if you have bandwidth to spare, you could install the whole thing with apt-get install texlive-full. However, distro repositories usually have older versions — Debian 5.0 Lenny has TexLive 2007; Squeeze has TexLive 2009. If you want the latest version, download it from the Tux Users Group site.

LaTeX IDE and compilation

After you create a .tex document, you need to compile it. The easiest way to do both is to use an IDE, which has built-in options for spell-checking, code folding, code completion, compilation and previewing. If you don’t have a LaTeX IDE installed, you would use the traditional way of compilation — which is to invoke the LaTeX command in a terminal, like latex test.tex. This will create a dvi file (and some others). You can view the output with xdvi test.dvi. To get a PDF output directly, you can run pdflatex test.tex. If you have an IDE, though, all these commands are done by it via GUI options.

There are lots of IDEs available for Windows and GNU/Linux; some major ones for Linux are Emacs + AUCTEX, Kile (KDE version), TexMaker, etc. Vim and Gedit have got some nice LaTeX plugins too.

An introduction to Beamer

If you installed TexLive minimal, you may not have the beamer class installed — so install it with apt-get install latex-beamer. Creating presentations with Beamer is simple if you know how to create documents with LaTeX. Here’s a simple Beamer file (results shown in Figure 1):

\documentclass{beamer}
\usetheme{Warsaw}
\title{Beamer - Introduction to \LaTeX presentation making}
\author{Jestin Joy}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Introduction}
\framesubtitle{Hello World Tutorial}
Hello World.
\end{frame}
\end{document}

An introduction to Beamer
Figure 1: An introduction to Beamer

The first line specifies the document class to use (beamer). Packages can also be used in a beamer class. The theme is specified by \usetheme{Warsaw}. Like a LaTeX document, the Beamer presentation is enclosed within the \begin{document} and \end{document} environment. A \begin{frame} is followed by the contents of the frame, and then by \end{frame}. The first frame above specifies the title slide, which contains the title and author name, with the given theme style. The next frame is the second slide, whose contents are obvious from the code.

Beamer’s power is not limited to nicely formatted slides — you can have transitions and animation too. Also, almost all LaTeX constructs can be used inside the beamer class. The commonly used ones are begin{itemize} and \begin{enumerate} environments, which provide bullets and numbering, respectively. Another useful one is \begin{block} add \end{block} environment, which helps highlight a specific piece of text. For example (results shown in Figure 2):

\begin{frame}
\frametitle{Introduction}
\framesubtitle{Hello World Tutorial}
\begin{block}{Beamer}
Hello World from Beamer
\end{block}
\end{frame}

Block
Figure 2: Block

Beamer has some built-in environments for definitions, theorems, lemma, proofs, corollaries, examples, etc., which we can use instead of using the block environment. For example, we can create an example block as follows:

\begin{example}
Hello World from Beamer
\end{example}

To add a table of contents, you can use the \tableofcontents environment inside a frame. Content information is taken from \section{} parts in the document. Beamer lets you give extra options within []. For example, to list the table of contents sections one after another, you can add the [pausesections] option to \tableofcontents, as follows: \tableofcontents[pausesections].

Options can be used elsewhere too — for example, for a custom title and author name in the footer section, use the following commands:

\documentclass{beamer}
\usetheme{Warsaw}
\title[Beamer Intro]{Beamer - Introduction to \LaTeX presentation making}
\author[J E S T I N]{Jestin Joy}

Overlays are used extensively when creating a MS PowerPoint presentation. Beamer also has overlay functionality, usually used along with the itemize or enumerate environment:

\begin{frame}
\begin{example}
Some good Latex Editors are
\begin{itemize}
\item<2-> Texmaker
\item<3-> Emacs + AUCTEX
\item<4-> Kile
\end{itemize}
\end{example}
\end{frame}

Here, the overlay specifications are used with the itemize environment, which displays data in a list. The numbers <2->,<3->… represent the order in which they are to be displayed. If <1-> is given, then the Texmaker option comes in the first time itself.

The number of slides needed is automatically computed by Beamer. The above frame needs four slides in total. A simple .tex file that includes the above techniques follows:

\documentclass{beamer}
\usetheme{Warsaw}
\title[Beamer Intro]{Beamer - Introduction to \LaTeX presentation making}
\author[J E S T I N]{Jestin Joy}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Outline}
\tableofcontents[pausesections]
\end{frame}
\section{Introduction}
\begin{frame}
\frametitle{Introduction}
\framesubtitle{Hello World Tutorial}
\begin{example}
Hello World from Beamer
\end{example}
\end{frame}
\section{Itemize example}
\begin{frame}
\begin{example}
Some good Latex Editors are
\begin{itemize}
\item<2-> Texmaker
\item<3-> Emacs + AUCTEX
\item<4-> Kile
\end{itemize}
\end{example}
\end{frame}
\end{document}

Beamer’s features are not limited to what’s been covered in this article, but include embedding dynamic effects, customising themes, layouts, fonts, and more. So… now that we have almost tamed Beamer, go start playing with it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here