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:

The Economist Illustrated:
Japan

abenomics Illustrated by: Joel Hopler


The Inspiration

The third arrow of Abenomics: Misfire

Illustrator’s Notes

This one’s pretty straight forward and there’s actually two articles that use the same imagery of the third arrow of “Abenomics” (see Shinzō Abe, current Prime Minister of Japan). I really couldn’t believe there wasn’t one image of an arrow and a target, so I just had to snatch that low-hanging fruit.

The Economist Illustrated:
Iran

Sanctions and Moonshine Illustrated by: Joel Hopler


The Inspiration

Iran and alcohol: Wet and dry

Illustrator’s Notes

I personally enjoy local moonshine and thought it was interesting that sanctions with negative intentions would aid the business of Armenia’s moonshine industry. Perhaps due to the sanctions, Iran will come around to ending their prohibition and begin a more nuanced approach towards alcohol through regulation.

The Economist Illustrated:
Pakistan

pakistan_drone Illustrated by: Joel Hopler


The Inspiration

Dealing with Pakistan’s extremists: The hawk and the dove

Illustrator’s Notes

This article had some really accurate and fun imagery so I just went straight for a direct illustration. The hawk represents the army chief of Pakistan and the dove represents the incoming prime minister. While they bicker about policies, there’s a U.S. drone in operation.

Economic Data Resources: South Africa

If, like me, you become interested in analyzing post-Apartheid South Africa, you will need to find as much good-quality data as you can get your hands on. Here are links to sources that I found useful: (Please add any resources you think are lacking in the comments below. I will update this post as I become aware of more resources.)

Country Profiles

These country profiles provide a handy overview and are useful for brainstorming regional research topics.

General Sources

These general sources are collected and maintained by South African institutions.

Household Surveys

  • KIDS dataset: this survey includes 3 waves – 1993, 1998, and 2004 covering the KwaZulu-Natal province.
  • NIDS dataset: wave 1 of this national survey covers 2008 while the second wave includes data from 2010 and 2011.
  • IPUMS – click on “Change Samples” to select the South African surveys
  • World Bank LSMS
  • World Bank Microdata

Other Projects on South Africa

Trade Statistics

GIS

The Economist Illustrated:
Gulf of Guinea

gulf_of_guinea Illustrated by: Joel Hopler


The Inspiration

The Gulf of Guinea: Another Somalia?

Illustrator’s Notes

I wanted to work out a modern interpretation of the classic pirate skull by pairing it with a modern gun. I also placed an American Bald Eagle who’s technically tied down to an anchor, but with a long leash. This is in reference to the article’s point that “[…] west African governments […] have so far not welcomed the idea of Western naval patrols.”

Using SourceTree and Git for Research (Part 2): Bitbucket

In the first part of this tutorial we created a local git repository with SourceTree, committed a change, and reviewed the commit history. Make sure you have either already completed the previous part of this tutorial, or that you already have a repository on SourceTree you want to link up with Bitbucket.org.

Making a remote version on Bitbucket

While you can create a new remote repository to connect to on Bitbucket.org, here we will do this from within SourceTree. Open SourceTree and click the “Settings” button. settings Click “Add”. remotes Click the button with a globe icon. globe Click the “Create New Repository …” button. create_new_button Fill out the new repository dialog. Set “Name” to “itn_project“, add a description if desired, and make sure to uncheck the “Publicly Visible” option. Finally, click “Create Repository”. create_new_dialog Notice that now you have an entry in your list for “itn_project” that is hosted by Bitbucket. Click “OK”. link_repository Set “Remote Name” to “itn_remote” and click “OK”. remote_name Click “OK” one last time. Finally, click the “Push” button to push the repository you have been working on to the remote one you just created. push_repo Make sure the “Local Branch” “master” is checked. Then click “OK”. Enter your password if requested to push the repository. push_repo2

Inviting a collaborator

Go to Bitbucket.org and login. Click on the “Repositories” menu at the top and choose your newly created repository. online_repo You should now see something like the following screenshot. This shows that your repository has been setup on Bitbucket.org. online_repo_overview Click the “Share” button. bitbucket_share Next, enter the email address (or Bitbucket username if you know it) of the collaborators you want to add to this repository (i.e. your coauthors) and then click the “Add” button. Here, I’m going to add Joseph Page (full disclosure: he’s my brother). bitbucket_share2 Before clicking “Share”, set the permissions of this new user of your repository. I set Joseph’s permissions to “WRITE” because I want him to be able to push commits to the repository (see the documentation for more details on permissions). bitbucket_share3 Click “Share” to invite your new collaborator. This will send a link which your collaborator can use to access the repository. Once they login to Bitbucket they will be able to access your repository.

Viewing a collaborator’s commit

Once your collaborator has pushed a commit (i.e. made changes and updated the repository) you will see this on the main page for your repository. collab_edit You can see Joseph left the following commit message:

made a few edits and added author name

Click on the link to the commit (see picture below). collab_edit2 This pulls up the summary of the latest commit. Scroll down to view the changes that were made. collab_edit3

Conclusion

This tutorial (and the previous one) merely scratched the surface of how leveraging DVCSs, such as git and hg, can enhance your research productivity. Using SourceTree, integrating these tools is easier than ever. Have fun with Bitbucket and let me know if you have any questions in the comments below!

The Economist Illustrated:
Pakistan

pakistan Illustrated by: Joel Hopler


The Inspiration

Pakistan’s waning feudalism: Gone with the wind

Illustrator’s Notes

I combined a few references made within the article to assemble an image of Jamshed Dasti. Since he’s the son of a wrestler I gave him a traditional wrestler’s mask and made sure to include the last sentence of the article where he mentions that deference is out. It was also mentioned that he’s “Pakistan’s answer to Robin Hood”, so I gave him the classic Robin Hood hat with a feather and a bow with an olive branch (for peace) instead of an arrow.

Using SourceTree and Git for Research (Part 1)

A Version control system (VCS) helps you manage changes to documents and programs. This goes beyond using Track Changes in Microsoft Word. For example, you can revert to older versions of a LaTeX document or program written in Stata, SAS, or R. With a distributed version control system (DVCS), you can track changes to all your documents and programs while collaborating with coauthors. Bitbucket offers for free an unlimited number of private repositories with up to 5 collaborators. If you authorize an academic (*.edu) email account you get unlimited contributors! A popular alternative is Github, but since Github does not offer free private repositories (and keeping your research private is important!) we will use Bitbucket. Bitbucket makes use of two DVCSs: Mercurial (Hg) and Git. We’ll be using Git for this tutorial, but you could use Mercurial instead if you prefer (intro to working with Mercurial). To make using git (and hg) a breeze, we will be using SourceTree, the free tool by Atlassian (makers of Bitbucket). Using a DVCS allows you to link a repository to the documents on your local machine. This repository will allow you to track changes to your documents and keep a record of your document history. To see how this system works. This tutorial will trace the following steps:

  1. Set up a project folder with a basic LaTeX file.
  2. Set up a Bitbucket account.
  3. Install SourceTree.
  4. Create a git repository using SourceTree.
  5. Make a change to our LaTeX file.
  6. Summarize basic features for reviewing changes.

Part 2 of this tutorial will cover connecting this repository to a Bitbucket.org repository to put the D in DVCS and take a look at collaborating with coauthors.

Step 1: Setup LaTeX file

  1. Create a new LaTeX file named “itn.tex”.
  2. Place this file in a folder that will only be used for this project.
  3. Place the following sample text in the file and save it.
    \documentclass{article} \title{International Trade Network} \author{Jonathan Page} \begin{document} \maketitle{} \section{Introduction} Careful analysis of the topology of the international trade network (ITN) is necessary in order to identify stylized facts which a theoretic network model of international trade should be able to replicate. Properties of networks are tightly related to the relevant network formation process. Determining the most appropriate network formation process can provide depth to related empirical analysis. \end{document}

Step 2: Setup a Bitbucket account

Go to bitbucket.org and sign up for a new account (if you don’t already have one). bitbucket_frontpage

Step 3: Install SourceTree

Go to http://sourcetreeapp.com/ and click the large “Download SourceTree Free” button in the middle of the page. Your button may appear different if you are using Windows. SourceTree Click the downloaded dmg file and drag the SourceTree application to your Applications folder. installSourceTree Open the SourceTree application. You will see a screen similar to the one below. Fill this form out with your fullname and the email address you used to setup your Bitbucket account. Make sure both check boxes are checked to allow SourceTree to manage your Mercurial and Git configurations and to agree to the license agreement. Click “Next”. Setup_SourceTree Enter your Bitbucket account information and click “Next”. Setup2_SourceTree Click “Finish” to complete the initial setup process.

Step 4: Setup your repository

Open finder and find the folder that contains your LaTeX file. Drag this folder onto the SourceTree application window. This will open the following dialog. new_repo_dialog Change the “Repository Type” from “Mercurial” to “Git” (you can also change the default bookmark name if you like). Click “Create”.

Add “itn.tex” to the staging area

Double-click the project to open the project view. Click “Add” to add all files in the folder to the repository. project_view Notice that “itn.tex” has been moved from “Files in the working directory” to “Files staged in the index”. This means that if we commit changes, changes to “itn.tex” will be updated to the repository. itn_staged

Commit to initialize the repository

Press the “Commit” button. commit This will bring up the dialog seen below. Add a meaningful message (always a good idea). Click “Commit”. commit_message

Step 5: Making a change to the LaTeX file

Now we want to see how this version control system deals with changes. Add the following paragraph to “itn.tex”:

In the analysis of international trade as a network phenomenon, we must answer the question of how the network structure is determined. More precisely, if we assume the network structure is given to us exogenously, our analysis will focus on the game played on the given network. If, however, the formation of the network structure is endogenous, our analysis must broaden to consider the formation process. This survey focuses on what information the network itself can provide regarding the formation process.

Save “itn.tex”. Open the SourceTree application. Notice that “itn.tex” now has a new icon beside it to indicate it has been changed. modified Click the file. This will show the changes you have made on the right. click_file_stage Click “Stage File” or “Add”. Click “Commit”, choose an appropriate message and click “Commit” to commit these changes to your repository.

Step 6: Viewing your history

Click the clock symbol to view the log. log_view Click the two log entries to see the changes that were added at each commit. Click “External Diff” to open another view of the differences between the selected commit and the one preceding it. Close the “External Diff” window. log_view2

Next Steps

We’ve covered quite a bit here, but there is much more to learn. Though our example worked with a LaTeX source file, you could follow the same process with any filetype. In fact, version control systems were developed with programmers in mind. As a result this is the perfect way to manage your source files for Stata, SAS, R, Python, HTML, etc. Here are a few git resources to get you started:

Be sure to check out the next part of this tutorial as we connect our repository to the Bitbucket site and collaborate with a coauthor. Any tips or nagging questions? I would love to hear them!

The Economist Illustrated:
India

angry_indians Illustrated by: Joel Hopler


The Inspiration

Angry young Indians: What a waste

Illustrator’s Notes

For this illustration, I wanted to showcase the experience of India’s youth as being represented by the goat pulling a cart. Down below, the goat can see a worse fate for itself in the goat head on a plater. Above is an old gorilla with a gavel, representing the politicians and government, hurtling obstacles for the goat to avoid (feel free to read into the Donkey Kong reference).