Setting Up Sublime Text with LaTeX

4 minute read

Introduction

In this series, we will be walking through how to set up Sublime Text Editor – a fast, flexible, and user-friendly text editor – for a variety of different programming languages and softwares. (For a more in-depth discussion on the value and pitfalls of Sublime, check out my previous post on Sublime and R.)

In this post, I will work through how to get Sublime set up to write in LaTeX, a typesetting software that is used by publishers and professionals alike. Easily customizable, LaTeX is often far preferred over processors like Microsoft Word in academia. It makes documents, posters, presentations, and other formats clean, clear, and professional.

For this tutorial, I am going to assume you already have Sublime downloaded and set up on your computer. If you haven’t done that yet, do it! Or at least, stop reading here, and go do something fun while there’s still time.

What is LaTeX and why is it useful?

LaTeX (pronounced lay-tek by some and lah-tek by others) is a software system used to typeset documents. Unlike programs like Word, which pre-define formats and layout of documents, LaTeX is a more flexible and customizable option. Unfortunately, this also means there is a bit more of a learning curve than a simple point-and-click system, as more options need to be defined ex ante. However, this program is quite simple and usually intuitive once mastered, and will soon Word feel clunky and restrictive.

Widely used in academia, becoming comfortable with LaTeX is a critical skill for many junior scholars. With it, one can produce beautiful tables, figures, articles, presentations, posters, C.V.s, resumes, books, cover letters, and a whole range of other documents. LaTeX is also highly functional in multilingual environments and non-Latin scripts, typesetting complex mathematical equations, and adding extensive tables.

To produce a LaTeX product, we will edit an input, through which the software will produce an output (usually a PDF) upon each build. This is in contrast with Mircosoft Word, where both of these are displayed to the user as one joint product. We won’t be covering how to format things in LaTeX here (check out one of many online tutorials here), but we will get everything set up.

Setting up LaTeX with Sublime

Downloading Software

Let’s start by downloading three pieces of software:

  • MiKTeX: Open-source TeX distribution

  • SumatraPDF: Lightweight, clickable PDF viewer

  • ImageMagick: Open-source software for editing and manipulating digital images

Follow the installation directions for each, and as always, be cognizant about what paths you are using to store the files.

Got them? Great.

Settings Adjustments

To set up LaTeX within Sublime, we need to ensure that Package Control is successfully installed. With Sublime open, click Ctrl + Shift + P. The dropdown Package Control display should appear, like this:

image-center

If it does not appear, try installing Package Control again.

Assuming you’re still on board, let’s change a few of the Package Control settings.

Follow the path to Package Control Settings: Preferences + Package Settings + Package Control + Settings

image-center

This will open up two panels. The left panel is preset settings, while the right is for user settings. We’ll be using the right one. Copy and add the following code:


{
	"bootstrapped": true,
	"in_process_packages":
	[
	],
	"installed_packages":
	[
		"Agila Theme",
		"CiteBibtex",
		"Citer",
		"Grammatical Framework",
		"ImageMagick",
		"knitr",
		"Language - Spanish",
		"LaTeX Word Count",
		"LaTeXing",
		"LaTeXTools",
		"LSP",
		"LSP-Grammarly",
		"LSP-ltex-ls",
		"LSP-R",
		"Package Control",
		"Pandoc",
		"R-Box",
		"R-IDE",
		"SendCode",		
		"sublime-github",
		"SublimeLinter",
		"SublimeLinter-contrib-write-good",
		"SublimeREPL",
		"Terminus",
		"View In Browser",
	],
}

The settings panels should look something like this:

image-center

Depending on what you use, your final packages will undoubtedly look different from mine!

Save and close the settings file. This will initiate Sublime to start downloading and setting up all the packages, and can take up to 15 minutes. Grab a coffee or a snack during this time.

In the meantime, we can adjust some of the other settings. Open Prefence settings by selecting Preferences + Settings.

Here you can customize the font size, color scheme, and other pretty factors to your heart’s content.

Once some time has passed, we can check if all the packages have been successfully installed by following: Preferences + Package Settings + Latex tools + Check system.

Sublime will run through the files and issue any warnings that arise. All programs should say ‘Available’.

Opening a Document

To build a PDF, open any .tex file (a LaTeX file) in Sublime. Note that if you have errors in your set up or formatting definition, the PDF may not compile. But as long as everything is working, the PDF should automatically be built upon CTRL + b and open in Sumatra.

Here are some other helpful editing tips:

  • On the associated Sumatra PDF, double click anywhere on the page, which will take you to the respective location in Sublime.

  • CTRL + r in Sublime shows all sections by their headers for easy navigation.

  • To select multiple lines simultaneously, hold down CTRL as you click.

  • You can save whole LaTeX projects, just like in R, with multiple folders (or carefully keep track of your paths).

  • LaTeX preambles (the bit that formats the document) can be a bit repeatitive. I often copy and paste, adjusting as needed to save time and reduce errors.

And with that, you are off to the races! Or at least, off to the publishers.