Using Sublime for LaTeX (and making it look good)

Sep 23, 2017 00:00 · 932 words · 5 minutes read LaTeX Sublime

Using Sublime is great. Doing LaTeX in a fast and minimalistic environment is basically the second best thing since sliced bread.

Why not combine the two? This post is nothing groundbreaking, as others have already covered this topic. What I aim to do here is to collect the fragments of advice and tips to have them all in one place to make it easier to do LaTeX with Sublime. But before any of those things a disclaimer is warranted: I haven’t used extensively other editors for LaTeX, so while I’m aware of Atom and VIM as great editors and TeXstudio and Texmaker (among many others) for Tex editing I cannot really comment on the differences between those and Sublime.

The end result

The end result

Sublime essentials

Sublime Text is a lightweight text editor that is super fast and flexible. The idea is that you can add packages to Sublime that makes it into a proper LaTeX editor, or even a Python or R IDE replacement without any loss of functionality (you can get the more detailed picture from Sublime’s web page as well as the software). It’s practically free, it will prompt you to buy a license at around every 100 save, but it can be ignored forever. Some of the things here apply to Sublime Text 2 and 3, although I only tested them with Sublime 3 on OSX and Windows 7 (you should use Sublime 3 anyways since 2 is not supported anymore as far as I know).

Setup and useful things for Sublime

The very first thing you need to install to Sublime is the Package Control, that is very easy and detailed here: https://packagecontrol.io/installation. From this point, the limit of what you can do with Sublime is endless.

If you work on multiple machines and over multiple systems, there’s good news! You can sync your installed packages and settings, so you don’t need to go through the whole process every time. All you need is a cloud service account (Dropbox or Google Drive) and the Package Syncing package. You can set up with the instructions provided here: https://github.com/csch0/SublimeText-Package-Syncing

Bracket highlighting: useful package, does what the name suggests and it is generally very helpful. You can find the info and install details here: https://github.com/facelessuser/BracketHighlighter

Themes and color schemes

On a more subjective topic, you can personalize your client with various color schemes and themes, there are hundreds out there (links are at the end of this post). Two great themes if you are not satisfied with the vanilla Sublime:

LaTex in Sublime

Now for the good stuff. There are two main packages for doing LaTeX in Sublime 2 and 3: LaTeXing and LaTexTools. The thing is that LaTeXing is not open source so I would recommend using LaTexTools as the developers and the community seems more active in fixing bugs and pushing updates. As with anything, it’s more about personal taste rather than a dealbreaker feature (if you are inclined, there’s a discussion thread up on StackExchange to see some other views and experiences).

The setup of LaTexTools is the most complex part of this enterprise but fortunately, the developers walk you through the whole process: https://latextools.readthedocs.io/en/latest/install/ . You can see the overview of the package on github: https://github.com/SublimeText/LaTeXTools. It can be a little long process, but worth the effort. (a more step-by-step tutorial is here: https://withgyanesh.wordpress.com/2015/05/22/latex-st/)

Now that the hard part is over, you are basically done. The joyful minutes of productive procrastination are over and you can now work on your tex file in Sublime. As this is not a LaTeX tutorial, I won’t (and probably can’t) go into details about that, but the internet is filled with great tutorials and templates. Sharelatex can be a nice browser based alternative (and great for collaborative projects) and a good starting point for said tutorials and templates.

The nice little things

However, you can enhance your experience with some added packages (let alone a few more minutes of the illusion that you spend your time productively while not writing).

Code autocomplete: https://github.com/LaTeXing/LaTeX-cwl. Easy to install and works with LaTexTools and LaTexing as well. The LaTexTools integration is not mentioned on the GitHub page, but it works with that as well.

Zotero bib file sync: if you use Zotero for managing citations and loathe to manually setup your bib files, good news (again)! You can set up Zotero with the BetterBibtex plugin to create a bib file from your selected folder that updates every time you make a change to it in Zotero. Install instructions: https://github.com/retorquere/zotero-better-bibtex/wiki/Installation

There is also a little outdated, but useful guide with detailed instructions from MIT that might be useful: http://libguides.mit.edu/c.php?g=176000&p=1159208

There is a linter package for Sublime that you can use for your project. To set it up for LaTeX you need to install SublimeLinter3 (https://github.com/SublimeLinter/SublimeLinter3), then install the ‘chktext’ plugin from package control (https://github.com/SublimeLinter/SublimeLinter-chktex).

Some additional good stuff

You can get a whole load of information organised into these awesome lists on GitHub, and I can highly recommend checking them out if you are interested in Sublime, Latex, or anything really.

awesome sublime @ github - An awesome collection of tutorials, packages, themes and color schemes, and anything related to Sublime. Highly recommended if you want to do more with Sublime besides LaTeX (Ruby, R, Python, Markdown for example).

awesome latex @ github - An awesome collection for LaTeX, not just with Sublime.