Introduction to Beamer

September 17, 2011
By

(This article was first published on We think therefore we R, and kindly contributed to R-bloggers)

A friend of mine, who is quite smart by the way (she is a PhD. student in Physics at Cambridge), recently asked me for some help with Beamer. Well most of my knowledge and code came from Utkarsh when I had started about a year ago. Initially, I had just asked him for some help with Ubuntu, then a little bit with R, and then some with LaTeX, followed a bit by Python. This was all accompanied with constant questions from my side regarding mathematics, programming, web scarping, regular expressions etc. Most of the times he ended up writing the entire code for me. Though this was more or less like spoon-feeding a kid, he made it a point to ensure that I understood what the code was doing. After writing a lot of code for me and fixing a lot of bugs in the code that I wrote, I finally started to get some confidence while writing my own scripts. A year later I realize that much of teaching much did not emphasize that I get the "grammar" of script right, but that I got the "approach" of the script right. To be more clear, it's more important to know exactly what we want are trying achieve through the code rather than the way to do it. If you know what you want, you'll figure out a way to get it.

Well, when my friend asked for some help with Beamer, I didn't know how to exactly go about it. Should I forward her some documentation that I have stored in my computer which I never read myself? Well, I did do that. But the idea was a bit discomforting. Also, all the time that Utkarsh spent with an idiot like me should not go waste. So I tried to recollect some of the things that he taught me, scrapped through some of my beamer presentations that I had made in college and organized it into a TeX document.

Hope it helps...

% This is a very humble attempt to introduce fellow students to amazing world of LaTeX, and more specifically Beamer.
% This by no means is a guide or a reference manual for Beamer. It is simply a beginning. If you are planning your first presentation, this should serve the purpose and at the same time arouse curiosity to delve deeper.
% Also, I would like to point out that most of the code here has been acquired from various secondary sources and are not
% my creation. I have just assembled some information that I have into a organized document. I sincerely thank all those creative individuals you were generous enough to share their solutions with the world.

\documentclass[]{beamer}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tabls}
\usepackage{booktabs}
\usepackage{float}
\usepackage{array}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage{subfigure} % This package is a very neat way to accommodate more than one graphic on one slide. A sample command is included for reference.

\newenvironment{wideitemize}{\itemize\addtolength{\itemsep}{10pt}}{\enditemize}
% Typically, the itemize enviroment does not provide adequate space between bullet points
% and hence can look a bit cluttered at times. The new "wideitemize" problem solves this issue.
% To use it just put your regular "\item" between "\begin{wideitemize}" and "\end{wideitemize}"

\hypersetup{% This can be left blank if information is not available
pdfauthor = {Author's name},
pdftitle = {Title for the pdf file},
pdfsubject = {},
pdfkeywords = {},
pdfcreator = {LaTeX with hyperref package},
pdfproducer = {dvips + ps2pdf}}

\mode<presentation> % This is a representative list of themes available is Beamer.        Shreyes prefers the Warsaw theme,  I prefer Pittsburg; it's much neater. 
                                   Also, CambridgeUS is quite popular among academics.
     %\usetheme{Warsaw}
     %\usetheme{Rochester}
     %\usetheme{Madrid}
     %\usetheme{Pittsburgh}
     %\usetheme{Antibes}
     %\usetheme{Montpellier}
     %\usetheme{Berkeley}
     %\usetheme{PaloAlto}
     %\usetheme{Goettingen}
     %\usetheme{Marburg}
     %\usetheme{Hannover}
     %\usetheme{Berlin}
     %\usetheme{Ilmenau}
     %\usetheme{Dresden}
     %\usetheme{Darmstadt}
     %\usetheme{Frankfurt}
     %\usetheme{Singapore}
     %\usetheme{Szeged}
     %\usetheme{Copenhagen}
     %\usetheme{Malmoe}
      \usetheme{CambridgeUS}
      \setbeamercovered{transparent = 28}
}


\usefonttheme{professionalfonts}
\usecolortheme[rgb={0.01,0.18,0.42}]{structure}
\useinnertheme{rounded}


\title{Sample Presentation}
\author{Author} \institute{My Institute}

\setbeamertemplate{footline}[frame number] 
% This shows the slide number at the bottom of the page. May or may not be required depending on the theme you use.

\beamertemplatenavigationsymbolsempty 
% This disables the navigation button in the lower right corner of the generated pdf file.


\begin{document}
\begin{frame} % Just so we are clear, a frame here means a slide.
\titlepage
\end{frame}


\AtBeginSection[] % This will display the list of contents before the beginning of each section
{
\begin{frame}
      \frametitle{Outline}
      \tableofcontents[currentsection]
\end{frame}
}


\begin{frame} % You can use this if you just want the list of contents to be displayed once at the beginning.
      \tableofcontents
\end{frame}


\section{Introduction}


\begin{frame}
      \frametitle{A simple sample frame}
            \begin{wideitemize}
                 \item Point 1
                 \pause
                 \item Point 2
                 \pause
                 \item Notice the space between the points.
                 \pause
                 \item Comparatively, more generous than the    normal ``itemize" enviroment
                 \pause
                \item Also, the sequential appearance of points is handeled with \textbackslash pause command.
            \end{wideitemize}
\end{frame}


\section{Part I}


\begin{frame}{Frames you can replicate} % You can include the frame title here as well.
      \begin{itemize}
            \item 1
            \item 2
            \item 3
            \item 4
            \item 5
      \end{itemize}
\end{frame}


\begin{frame}{Another one you can replicate} % This one uses wideitemize
      \begin{wideitemize}
            \item 1
            \item 2
            \item 3
            \item 4
            \item 5
      \end{wideitemize}
\end{frame}


\begin{frame}{Nested environments}
      \begin{wideitemize}
             \item This is wideitemize environment
             \item You can nest environments to formulate a 
hierarchical structure
              \item See below

                   \begin{itemize}
                       \item This is itemize
                       \pause
                       \item Notice the space between bullets
                       \pause
                       \item The bullets can be changed to number using the enumerate environment
                       \pause
                       \item \LaTeX is cool
                       \pause
                       \item I am glad you chose to give it a
thought
                       \pause
                       \item It will change the way you work
                   \end{itemize}

      \end{wideitemize}
\end{frame}


\section{Part II}


\begin{frame}{subfigure example}
      \begin{figure}
            \centering
            \subfigure[Figure 1]{
            \includegraphics[scale=0.4]{name_of_figure1_file.pdf}
            \label{model1}}  % Try putting labels for every figure, table, and equation. It will become easier to navigate if the document is huge.           
            \subfigure[Figure 2]{
            \includegraphics[scale=0.4]{name_of_figure2_file.pdf}
            \label{model2}}
      \end{figure}
\end{frame}


\begin{frame}{Math in \LaTeX}
      \begin{enumerate} 
          \item Use the ``align" or ``gather" environment for math
             \item They are neater
             \item You can also use the ``equation" and ``eqnarray" envrionments
             \item Also, notice that this is the enumerate environment
             \item Hence the numbers instead of bullets
       \end{enumerate}
\end{frame}


\centering
     \frame[plane]{
           \vspace{2cm}
                  {\huge Thank you} % Huge makes the text size, well, Huge
           \vspace{3cm}
           \begin{flushright}
                  Author name and contact
           \end{flushright}
}


\end{document}  
   

To leave a comment for the author, please follow the link and comment on his blog: We think therefore we R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.