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.

Snippet Breakdown

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).

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.

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.

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.