This is the first illustration in our new series, The Economist Illustrated. Each illustration will include notes from the illustrator. Illustrated by: Joel Hopler Continue Reading
The Economist Illustrated:
Nigeria – Clubbing Together
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
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
#! (Crunchbang) for Economists
This guide walks you through my current setup of a (mostly) open source system for conducting economic research. There is actually a substantial amount of work involved in setting up this system. 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