# Jeromy Anglim's Blog: Psychology and Statistics

## Wednesday, August 25, 2010

### Simple Beamer Template for Getting Started and Reducing Typing

For those who don't already know, Beamer is a useful package in LaTeX for preparing slide presentations. I have a Beamer template of preamble and slide templates. I found having a template was useful: (a) when first learning Beamer commands, and (b) in order to save typing. Thus, this post shares and explains the template in case it was of interest to others. It includes both my standard preamble and templates for individual slides. It is designed so that it is easy to compile both a presentation and a 2 x 2 handout.

### Overview of Using the Code

At the risk of stating the obvious, I use the template as follows.
1. When beginning a new presentation three text files are created (substituting the word "content" for the name of the talk): (a) handout_content.tex, (b) presentation_content.tex; (c) content.tex.
• presentation_content.tex contains just the two lines as shown under (1) below.
• handout_content.tex contains just the two lines as shown under (2) below.
• content.tex contains the preamble as shown under (3) below.
2. The slide templates under (4) are copied and pasted into content.tex as needed to prepare the presentation.
3. presentation_content.tex is compiled while preparing the talk. handout_content.tex is compiled only once the presentation is finalised.

### The Beamer Template Code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1. Presentation header file (in separate file)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[t]{beamer}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 2. Handout header file (in separate file)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[handout, t]{beamer}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<beamer>{
\usetheme{Frankfurt}
}
\mode<handout>{
\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper, border shrink=10mm, landscape]
\usetheme{default}
}

\title{}
\subtitle{}
\author{}
\institute{}
\date{}

\begin{document}
\mode*
\begin{frame}
\titlepage
\end{frame}

\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}

\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 4. Templates for individual slide types
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Slide at the beginning of a section
\begin{frame}{Outline}
\tableofcontents[currentsection]
\end{frame}

% Simple slide
\begin{frame}{}
\begin{itemize}
\item
\end{itemize}
\end{frame}

% Slide with a block
\begin{frame}{}
\begin{block}{}
\begin{itemize}
\item
\end{itemize}
\end{block}
\end{frame}

% Slide with example (different colour to Block)
\begin{frame}{}
\begin{example}
\begin{itemize}
\item
\end{itemize}
\end{example}
\end{frame}

% Slide with two columns
% (0.5 can be adjusted but should generally sum to 1.0)
\begin{frame}{}
\begin{columns}
\begin{column}{0.5\textwidth}
\end{column}
\begin{column}{0.5\textwidth}
\end{column}
\end{columns}
\end{frame}

% Verbatim
\begin{frame}[fragile]{}
\begin{verbatim}
% code
\end{verbatim}
\end{frame}

% slide with title and figure
\begin{frame}{}
\begin{center}
\includegraphics[width=11cm]{files/figure}
%\caption
\end{center}
\end{frame}

% Full screen image
\mode<all>
{\usebackgroundtemplate{\includegraphics[width=\paperwidth]
{files/figure}} %replace files/figure with file path and name
\begin{frame}[plain]
\end{frame}}
\mode<all>{\usebackgroundtemplate{}}
\mode*

% Basic centred table with alternating colour rows
% \usepackage{xcolor}
% \documentclass[xcolor=pdftex,dvipsnames, table]{beamer}
\begin{frame}{}
\begin{center}
\rowcolors{1}{\RoyalBlue!20}{\RoyalBlue!5}
\begin{tabular}{lll}\hline
A & B & C \\
\end{tabular}
\end{center}
\end{frame}

% Frame with incrementally displayed dot points with an alert
\begin{frame}{}