First Beamer Presentation with LaTeX and Sublime Text 2

This tutorial will walk you through the creation of your first beamer presentation using LaTeX and Sublime Text 2. I will assume you have at least made your first PDF with LaTeX in Sublime Text 2 (Mac-specific setup instructions).

Create beamer_test.tex

Start by opening Sublime Text 2, and saving a new document as “beamer_test.tex“. On the first line we’ll set the document class to “beamer“:

\documentclass{beamer}

On the next line, type “begin“, then press the TAB key. This should paste the following snippet and place cursors selecting “env” in both the begin and end tags:

\begin{env} \end{env}

Now type “document” so that environment tags look as follows:

\begin{document} \end{document}

Adding slides (um,… I mean frames)

Frames in beamer presentations are (for our purposes) the equivalent of slides in PowerPoint presentations. To add a frame inside of our document environment, simply type “frame” and press the TAB key (this and the last snippet assumes you have LaTeXTools installed). Go ahead and change “title” to “My First Slide“. Add some content inside the frame (I’m going to add a bulleted list). Your new slide should look similar to the following:

\begin{frame}[t]\frametitle{My First Slide} \begin{itemize} \item My first point \item My second point \item My third point \end{itemize} \end{frame}

Here I added an itemized list, but inside of these frames you can place figures, tables, equations and anything else defined in LaTeX. Ok, now that we have one of the most basic presentations known to man, let’s hit CTRL+B (or COMMAND+B on OS X) to build this presentation (if you get a few font warnings, don’t worry, fixing these is not important). Your finished slide should look like this: first_slide Now, I admit, this is a little underwhelming. So, let’s add a title page, make it so the frame content is not top-aligned, and play around with some themes while we’re at it.

Adding a title page

What presentation would be complete without a title page. First we need to define the elements of the title page. Paste the following commands between the document class statement and before the beginning of the document environment.

\title[Short Presentation]{The shortest presentation in \LaTeX} \subtitle[title edition]{Now with a title} \author[F. Lastname]{Firstname Lastname} \institute[UIR]{ The University of Irreproducible Results }

Making the title page is pretty easy. Just paste the following frame above the first one we made earlier.

\begin{frame}[plain] \titlepage \end{frame}

Here we replace the frame title and the t (top-align) option with the plain option. Go ahead and build the PDF. Here’s what the first slide should look like: beamer_title

Changing alignment

So let’s say you don’t want the frame content vertically aligned to the top. Simply change the “[t]” to “” (or “[b]” if you want it bottom-aligned). You can also remove “[t]” entirely to use the default which is centered.

Adding themes

Time to spice up our rather bland presentation. Hop on over to the Beamer Theme Matrix and pick out a theme. The city names along the side are beamer themes which will go inside a usetheme command and the animal names along the top are color themes which will go inside a usecolortheme command. I’ve chosen beamer theme “Szeged“, and color theme “dove.” Add the next commands between the document class command and the title info we inserted earlier (replace Szeged and dove for themes you chose).

\usetheme{Szeged} \usecolortheme{dove}

The finished presentation

Here’s what the slides for our completed presentation look like. title_dove slide_dove Here’s the complete source:

\documentclass{beamer} \usetheme{Szeged} \usecolortheme{dove} \title[Short Presentation]{The shortest presentation in \LaTeX} \subtitle[title edition]{Now with a title} \author[F. Lastname]{Firstname Lastname} \institute[UIR]{The University of Irreproducible Results} \begin{document} \begin{frame}[plain] \titlepage \end{frame} \begin{frame}\frametitle{My First Slide} \begin{itemize} \item My first point \item My second point \item My third point \end{itemize} \end{frame} \end{document}

Conclusion

While this is a presentation short on finesse and content, I hope it helps get you started. Be sure to come back for a follow-up tutorial taking your skills with ST2 and beamer to the next level. In the meantime here are some resources I have found useful:

And here are a few of our tutorials on Sublime Text 2 and LaTeX in general:

Sublime Text 2: Tips, Tricks, and More

Here are a few of my favorite Sublime Text 2 features will blow your mind if you’re new to the wonderful world of this powerful editor. If you have seen these before, consider this a handy reference. Continue Reading

LaTeX Snippets Collection

This post presents snippets that help make paper writing a breeze in Sublime Text 2 (see my earlier post on how to create snippets, this should also help you if you are confused by the overall structure of Sublime Text 2 snippets). Skip to the end of this post to download the snippets. You will need to copy them to your Packages/User folder. You can access this folder in the Sublime Text 2 menu by selecting Preferences > Browse Packages ..., and then selecting the User folder.

Article Snippet

<snippet>
  <content><![CDATA[ 
    \documentclass[12pt]{article}
    \usepackage{ctable,microtype,natbib,amsmath,amssymb,fullpage,graphicx}
    \usepackage[colorlinks,linkcolor=black,citecolor=blue,urlcolor=black]{hyperref}
    \usepackage{setspace} 
    \onehalfspacing 
    
    \title{${1:Title}} 
    \author{${2:Author}} 

    \begin{document} 
      \maketitle{}

      \begin{abstract}
      \end{abstract}
    
      \section{Introduction}
        ${3:Start typing here}

      \bibliographystyle{apalike}
      \bibliography{path-to-bib/filename}{}
    \end{document} 
]]></content> 
  <tabTrigger>article</tabTrigger>
  <scope>text.tex.latex</scope>
</snippet>

Snippet Breakdown

For details on the packages included via the

\usepackage

command, see my previous Latex package reference.

 \title{${1:Title}} \author{${2:Author}} 

After first triggering this snippet, your cursor will be placed in the title command selecting the text “Title“. Subsequently pressing TAB will move the cursor to select “Author“, and finally the text “Start typing here“. I would recommend changing “Author” to your name, especially if you anticipating authoring most of your documents without coauthors.

 \maketitle{} 

This command creates the title using the information from the title and author commands. Place your abstract in the abstract environment.

 \bibliographystyle{apalike} \bibliography{path-to-bib/filename}{} 

These lines set the biblography style and find your BibTeX file, in this case named “filename.bib”. Simply change path-to-bib to the relative path (relative from your *.tex file) to your *.bib file if you plan on authoring most of your documents where they can access the *.bib file using the same relative path. Otherwise, change path-to-bib to the absolute path to your main *.bib file. This works especially well if you prefer a mammoth *.bib (one *.bib to rule them all).

ctable Snippet

 <snippet> <content><![CDATA[ \ctable[ caption=${1:Table Title} label=tab:${2:tblname} ]{${3:ccc}}{ \tnote[]{This note does not have a corresponding mark} \tnote[a]{This note does have a mark} }{ \toprule ~ & Cooperate & Defect \\ %\midrule % midrules are useful for tables with a clear heading row Cooperate & (8,8) & (0,10) \\ Defect & (10,0) & (3,3) \\ \bottomrule } ]]></content> <tabTrigger>ctab</tabTrigger> <scope>text.tex.latex</scope> </snippet> 

Snippet Breakdown

This snippet provides a basic table using the ctable package.

 caption=${1:Table Title} label=tab:${2:tblname} 

This first section is like a preamble to the table and sets up the title and the label which we can use later in a \ref command to create a reference to the table number (TIP: use the table snippet that comes with Sublime Text 2 to start a reference to a table). Note that the text “Table Title” will be selected first, followed by “tblname“, and finally by “ccc” in the TAB order.

 ]{${3:ccc}}{ 

This line sets the format of the table to three centered columns.

 \tnote[]{This note does not have a corresponding mark} \tnote[a]{This note does have a mark} 

The third section defines any notes you want to appear at the bottom of the table.

 \toprule ~ & Cooperate  & Defect \\ %\midrule % midrules are useful for tables with a clear heading row Cooperate & (8,8) & (0,10) \\ Defect & (10,0) & (3,3) \\ \bottomrule 

The final section is where you place the table content as you would with the booktabs environment.

LaTeXTools Snippets

The below snippets are subject to change at the whim of its maker. Check the LaTeXTools readme for notes on the current version. Any updates loaded onto your version of Sublime Text 2 should also load a document summarizing the changes.

bfigure

This trigger (bfigure) produces the following in your LaTeX document:

 \begin{figure}[tb] \begin{center} \includegraphics[]{} \end{center} \caption{Caption here} \label{fig:figure1} \end{figure} 

Changing

 \includegraphics[]{} 

to

 \includegraphics[width=\textwidth]{filename} 

would place the image “filename” in your document and scale it to the width of the text in your document.

Keybindings

There are keybindings set to make text bold, italicized, and underlined. To make the selected text bold press CTRL+L then CTRL+B in sequence (you can hold down CTRL throughout this process). For italics the second step is CTRL+E (for emphasis). For underlining the second step is CTRL+U. (For Mac OS X you should change CTRL to CMD)

Final Notes

You can always change the tabTrigger in these snippets. In fact, it’s a good idea to try typing the trigger I have chosen (or your preferred alternative), and compare it to the current snippets list (accessed in the menu by selecting Tools > Snippets.... This should also show you the snippets loaded by LaTeXTools, which you really should have running (see our previous tutorials here and here). To setup the above snippets, download the following files and copy them to your Packages/User folder. You can access this folder in the Sublime Text 2 menu by selecting Preferences > Browse Packages ..., and then selecting the User folder.

Files

LaTeX_article.sublime-snippet LaTeX_ctab.sublime-snippet

Useful LaTeX Packages

This reference introduces you to the LaTeX packages I load using a snippet every time I start a new LaTeX document (using the article document class). Continue Reading

Making your first PDF with LaTeX and Sublime Text 2 for Mac

Why use LaTeX? LaTeX is the standard typesetting for economists. Equations are easier to type, making citations is a breeze, and your finished paper just looks more beautiful. Continue Reading

Creating Snippets in Sublime Text 2 for LaTeX

Ever realize you seem to type the same block of text every time you create a new document? If you haven’t already, now is the time to introduce yourself to snippets. In this tutorial we will walk through the creation of snippets in Sublime Text 2 for LaTeX. Continue Reading

Making your first PDF with LaTeX and Sublime Text 2

This tutorial will walk you through the installation and setup of Sublime Text 2 for working with LaTeX. After installation we will create a simple PDF to make sure everything has been setup correctly. Continue Reading