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>
<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>
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>
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.
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.
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
)
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.
Quick Links
Legal Stuff
Social Media