In the last post we looked at adding some more interesting content into our presentation. In this post we’re going to look at animating our slides.

##The Pause Command Often when when doing a presentation we’ll want to reveal parts of a frame one after the other. The simplest way to do this is to use the \pause command. For example, by entering the \pause command before every entry in a list we can reveal the list point by point:

\begin{frame}
\frametitle{List}
\begin{itemize}
\pause
\item Point A
\pause
\item Point B
\begin{itemize}
\pause
\item part 1
\pause
\item part 2
\end{itemize}
\pause
\item Point C
\pause
\item Point D
\end{itemize}
\end{frame}


This brings us on to the difference between a frame and a slide. A single frame is defined as what we build up in a single frame environment, whereas a slide is a single page in the resulting pdf. This means that a frame can be made up of multiple slides. For example, this frame with the list that we’ve just animated is made up of seven slides, but the frame number in the bottom right hand corner of each slide remains unchanged for all of the seven.

##Overlay Specifications The pause command is useful but isn’t very versatile. To get more flexibility we use what beamer calls ‘overlay specifications’. These specifications can be added to compatible commands using pointed brackets after the command name. For example I can add them to the \item command in a list structure like this.

\begin{frame}
\frametitle{More Lists}
\begin{enumerate}[(I)]
\item<1-> Point A
\item<2-> Point B
\begin{itemize}
\item<3-> part 1
\item<4-> part 2
\end{itemize}
\item<5-> Point C
\item<6-> Point D
\end{enumerate}
\end{frame}


The numbers inside the pointed brackets tell LaTeX which slides the item should appear on. For example, in this list we’ve told each list item which slide number it should first appear on and then told them to appear on all subsequent slides in the frame using the dash. Here’s an example of a more complicated overlay:

\item<-2,4-5,7>


This makes the item appear on slides 1,2,4,5 & 7.

There are a number of commands that enable us to use overlays on text. The main one is the \onslide command which can be configured to achieve a few different outcomes, details of these can be found in the documentation.

\begin{frame}
\frametitle{Overlays}
\onslide<1->{First Line of Text}

\onslide<2->{Second Line of Text}

\onslide<3->{Third Line of Text}
\end{frame}


When we simply give this command text as an argument, it acts in the same way as the \uncover command making the text fully appear only on the specified slides. On unspecified slides the text is covered, so will still take up space but won’t be visible.

To make the text transparent on unspecified slides we use the \setbeamercovered command and enter the keyword ‘transparent’ above the code where we want it to have an effect:

\setbeamercovered{transparent}


Please be aware that this command will affect all of the code following it, so if we want to change it back to the default setting later in the presentation we can simply use the same command again but with the keyword ‘invisible’.

Another command we can use is the \visible command which does the same as \uncover except it leaves the space blank on unspecified slides instead of transparent even if we’ve set the transparency as we did a moment ago. The \invisble command does the exact opposite to of the \visible command. The \only command does the same as the \visible command except it doesn’t take any space up. This means that if we change the \onslide commands to \only commands and get rid of the dashes in the overlay specifications our three lines of text will appear in the same place on the frame in turn.

\begin{frame}
\frametitle{Overlays}
\only<1>{First Line of Text}

\only<2>{Second Line of Text}

\only<3>{Third Line of Text}
\end{frame}


##Overlays and Text Formatting There are a number of commands to do with text formatting that are compatible with overlay specifications. These commands are simply ignored on slides not declared in the specification and will therefore just print the text as normal. Here are some examples:

\textbf<2>{Example Text}

\textit<2>{Example Text}

\textsl<2>{Example Text}

\textrm<2>{Example Text}

\textsf<2>{Example Text}

\textcolor<2>{orange}{Example Text}

\structure<2>{Example Text}


Which will produce text like this on the first slide:

And then like this on the second slide:

First the \textbf command which makes the text bold, then \textit which puts the text in italics, then \textsl which make it slanted, \textrm which uses the roman font family, \textsf which uses the sans serif font family but this doesn’t change anything because we are already using this font. Next the \textcolor command which puts it in the specified colour, then \alert which puts the text in red by default and finally the \structure command which formats the text in a way that indicates the presentations structure.

##Overlays and Environments Overlay specifications often work with environments as well. For example we could animate the environments on the maths blocks page like this:

\begin{frame}
\frametitle{Maths Blocks}
\begin{theorem}<1->[Pythagoras]
$a^2 + b^2 = c^2$
\end{theorem}
\begin{corollary}<3->
$x + y = y + x$
\end{corollary}
\begin{proof}<2->
$\omega +\phi = \epsilon$
\end{proof}
\end{frame}


Notice that with environments we put the overlay specification after the curly brackets instead of before.

You will also notice that turning the transparency setting on earlier in the document has affected the overlays here.

##Overlays and Tables Finally we may want to animate a table so that the rows appear slide by slide. To do this we use the \onslide command like this. We also need to make sure we reset the \setbeamercovered{} command to the default for this to work:

\setbeamercovered{invisible}
\begin{frame}
\frametitle{Tables}
\begin{table}
\begin{tabular}{l | c | c | c | c }
Competitor Name & Swim & Cycle & Run & Total \\
\hline \hline
John T & 13:04 & 24:15 & 18:34 & 55:53 \onslide<2-> \\
Norman P & 8:00 & 22:45 & 23:02 & 53:47 \onslide<3->\\
Alex K & 14:00 & 28:00 & n/a & n/a \onslide<4->\\
Sarah H & 9:22 & 21:10 & 24:03 & 54:35
\end{tabular}
\caption{Triathlon results}
\end{table}
\end{frame}


This concludes our discussion on animating our presentation. In the next post we’ll look at the different themes available in beamer and we’ll look at printing handouts. Please do keep in touch with us via Facebook, Twitter & Google+.

###Other posts in this series:

pt 1 - Getting Started

pt 2 - Lists, Columns, Pictures, Descriptions & Tables

pt 3 - Blocks, Code, Hyperlinks & Buttons

pt 5 - Themes and Handouts

Posted by Josh Cassidy on 20 Aug 2013

In the last post we looked at adding some basic content into our presentation. In this post we’re going to look at adding some other types of content.

##Blocks One of the ways beamer lets us display information on slides is using ‘blocks’. To do this we use the ‘block’ environment.

\begin{block}{Block Title}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\end{block}


At the end of the begin command we simply enter the block’s title in curly brackets. Then whatever we enter in between the begin and end commands, forms the content of the block. This is what it looks like:

There are quite a few variations of the block environment that help us produce blocks for different purposes. The first is the ‘alertblock’ environment which is similar to the block environment except its colour is red instead of blue.

\begin{alertblock}{Block Title}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.


Then there’s the definition environment which produces a standard blue block but with the title already specified as ‘definition’.

\begin{definition}
A prime number is a number that...
\end{definition}


Next there’s the example environment which produces a green block with the title ‘Example’.

\begin{example}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\end{example}


There is also a group of blocks that are especially useful for presenting mathematics. For example the ‘theorem’ environment, the ‘corollary’ environment and the ‘proof’ environment.

\begin{theorem}[Pythagoras]
$a^2 + b^2 = c^2$
\end{theorem}
\begin{corollary}
$x + y = y + x$
\end{corollary}
\begin{proof}
$\omega +\phi = \epsilon$
\end{proof}


The theorem and corollary environments automatically put their content in italics. These two also allow us to add extra content to the block title in parenthesis by adding text into square brackets at the end of the begin command. It’s worth mentioning at this point that beamer automatically loads the amsmath package so you can add more complicated mathematics straight away.

##Code Now let’s talk about adding code into slides. This is particularly important for any computer science related presentation. To do this we use the ‘semiverbatim’ environment. In order to use this environment on a frame, we need to add the ‘fragile’ option into the \begin{frame} command. Now whatever text we enter in the environment will appear as written, except for the backslash, open curly bracket and close curly bracket characters, which will continue to behave as they normally would in LaTeX. Therefore if we want to print some code which includes these characters we need to add an extra backslash before each of them. Here’s an example printing the code we used for the title slide.

\begin{frame}[fragile]
\frametitle{Including Code}
\begin{semiverbatim}
\\begin\{frame\}
\\frametitle\{Outline\}
\\tableofcontents
\\end\{frame\}
\end{semiverbatim}
\end{frame}


##Hyperlinks & Buttons Finally I want to discuss adding hyperlinks to our presentation. Before we can create any hyperlinks we need to tag the frames we want to link to using the \label command. For example, we’ll add a label to the contents frame, the columns frame and the pictures frame. E.g.

\begin{frame}
\label{contents}
...


Then we use the \hyperlink command to insert a link.

\hyperlink{contents}{click here}


In the first set of curly brackets we enter the label of the target frame and in the second set we add the text that we want to be clickable. Now if we compile the document you’ll see the text is now a clickable link. Beamer also allows us to use buttons. To do this we simply add a button command into the second set of curly brackets. For example, we’ll swap the ‘click here’ text for the \beamerbutton command and enter in curly brackets the text we want to appear on the button.

\hyperlink{contents}{\beamerbutton{contents page}}


Here are some other button commands we can use.

\hyperlink{columns}{\beamergotobutton{columns page}}



The beamer go to button, the beamer skip button and the beamer return button.

This concludes our second discussion on adding content to our presentation. In the next post we’ll look at animating our presentations. Please do keep in touch with us via Facebook, Twitter & Google+.

###Other posts in this series:

pt 1 - Getting Started

pt 2 - Lists, Columns, Pictures, Descriptions & Tables

pt 4 - Overlay Specifications

pt 5 - Themes and Handouts

Posted by Josh Cassidy on 16 Aug 2013

In the last post we looked at getting started with beamer. In this post we’re going to look at adding some different types of content into our presentation.

##Lists First let’s talk about lists. Lists are a common way to present information in presentations and they’re very easy to set up. Just like in a normal LaTeX document we can use the ‘itemize’ and ‘enumerate’ environments. Let’s use the ‘itemize’ environment to add in some bullet points. In between the begin and end commands we use the \item keyword to separate our list entries. We can also nest lists within other lists. Here’s an example:

\begin{frame}
\frametitle{List}
\begin{itemize}
\item Point A
\item Point B
\begin{itemize}
\item part 1
\item part 2
\end{itemize}
\item Point C
\item Point D
\end{itemize}
\end{frame}


And this is what it will look like:

The ‘enumerate’ environment is similar to the ‘itemize’ environment except it numbers items:

We can change the numbers to roman numerals by adding a capital ‘I’ in square brackets at the end of the begin command. Or we can use lower-case roman numerals by using a lower case ‘i’. E.g.

\begin{enumerate}[I]
\item Point A
\item Point B
\begin{enumerate}[i]
\item part 1
\item part 2
\end{enumerate}
\item Point C
\item Point D
\end{enumerate}


We can even surround the numerals in parenthesis like this:

\begin{enumerate}[(I)]
...
\begin{enumerate}[(i)]
...


Finally we can also nest an ‘itemize’ environment inside an ‘enumerate’ environment or vice versa to produce something like this:

##Columns Now let’s talk about columns. To organise text into columns we use the ‘columns’ environment. Then to start a column we use the \column command followed by a width. We’ll add in two columns both with a width of half the text width:

\begin{frame}
\frametitle{Using Columns}
\begin{columns}
\column{0.5\textwidth}
<text>
\column{0.5\textwidth}
<text>
\end{columns}
\end{frame}


##Pictures Now if we wanted to replace the second column of text with a picture we could simply replace the text with a \includegraphics command. We don’t need to load up the ‘graphicx’ package because beamer automatically loads it. We’ll also add the \centering command in to put the image in the centre of the column.

We can also use the ‘figure’ environment when adding in images. Here’s an example:

\begin{frame}
\frametitle{Pictures}
\begin{figure}
\includegraphics[scale=0.5]{lion}
\caption{lion!!}
\end{figure}
<text>
\end{frame}


Notice I’ve scaled the image down and given it a caption.

##The Description Environment Next we’ll look at the ‘description’ environment which is a type of list environment. Again we use the \item command but this time we pass it an argument in square brackets. The text we enter in the brackets will appear on the slide in a different colour to the following text. This environment is great for listing definitions. E.g.

\begin{description}
\item[API] Application Programming Interface
\item[LAN] Local Area Network
\item[ASCII] American Standard Code for Information Interchange
\end{description}


##Tables Finally let’s finish by adding a table to a slide. Just like adding a table into a normal document we use the ‘tabular’ environment to create the actual table and then enclose it in the ‘table’ environment to give us more options like adding a caption.

\begin{table}
\begin{tabular}{l | c | c | c | c }
Competitor Name & Swim & Cycle & Run & Total \\
\hline \hline
John T & 13:04 & 24:15 & 18:34 & 55:53 \\
Norman P & 8:00 & 22:45 & 23:02 & 53:47\\
Alex K & 14:00 & 28:00 & n/a & n/a\\
Sarah H & 9:22 & 21:10 & 24:03 & 54:35
\end{tabular}
\caption{Triathlon results}
\end{table}


###Other posts in this series:

pt 1 - Getting Started

pt 3 - Blocks, Code, Hyperlinks & Buttons

pt 4 - Overlay Specifications

pt 5 - Themes and Handouts

Posted by Josh Cassidy on 14 Aug 2013