A return to LaTeX with new tools

When I was writing up my Master’s and PhD assignments and dissertations, I used MiKTeX on Windows. My editor was a dedicated one called WinEdt. As I recall, WinEdt was a bit complicated to set up, but once it was to my liking, I found it the best out there.

When I started using LaTeX on a Mac, in the guise of MacTeX, I was disappointed by the editors. What I really wanted was a MacEdt, but no such thing existed. After a while, I had little need to use LaTeX, so I forgot all about it.

I’ve recently gone back to using LaTeX, this time for my writing. For programming, I’ve grown to like Sublime Text, so I decided to use it for LaTeX, compiling it by running pdflatex from the command line. Instead of the native Preview app, which doesn’t update the file behind the scenes after changing it elsewhere, I used Skim. It has a setting where you can make it automatically update the file if it’s been changed. I liked this, but it was a bit tedious, having to click in the command line app, run pdflatex, then switch to Skim to view the resulting PDF file. What I wanted was a way to make Sublime Text do all that for me.

LaTeXTools plugin for Sublime Text

I found a way. I was delighted to discover the LaTeXTools plugin for Sublime Text, which integrates with Skim.

How to set up Skim

Open up the Skim settings: Skim > Preferences…. Contrary to how I had my settings before, Skim is set to not update the file if it detects changes, and the PDF-TeX Sync support is set to Sublime Text:

Skim settings needed to synchronise building LaTeX with Sublime Text

How to set up Sublime Text

The set-up of Sublime Text may seem daunting, but it’s not really.

Sublime PDF viewer settings

In Sublime Text, you need to check the LaTeXTools settings – Sublime Text > Preferences > Package Settings > LaTeXTools > Settings – Default (read-only) – are set to the Mac OS default:

// ------------------------------------------------------------------
// Viewer settings
// ------------------------------------------------------------------
	// OPTION: "viewer"
	// Specifies which viewer to use
	// Possible values:
	// "default" or ""    the default viewer for your platform, which
	//                    is sumatra on Windows, skim on OS X and
	//                    evince on linux
	// "command"          invokes a viewer based on commands configured
	//                    in viewer settings below; see the README
	//                    for details
	// "evince"           uses Evince; this is the default on linux
	// "okular"           uses Okular to open the pdf
	// "preview"          uses Preview.app to open the pdf
	// "skim"             uses Skim to open the pdf; this is the
	//                    default on OSX
	// "sumatra"          uses SumatraPDF; this is the default on
	//                    Windows
	// "zathura"          uses Zathura to open the pdf
	"viewer": "",

Windows, Linux and Mac OS (OS X) each have a default PDF viewer, which is selected automatically by default. Assuming you have the relevant PDF viewer installed, you shouldn’t have to change the viewer setting here.

This works for me because it will open Skim on my Mac, so I left this setting alone.

Selecting a LaTeX compiler

Next, you have to set which LaTeX compiler you want Sublime Text to build your LaTeX projects with; you can do this from Tools > Build System > Automatic then Tools > Build System > Build With….

To run the compiler, press command+b. Hopefully, there will be no errors or warnings, and your PDF will open/update in Skim automagically.

Project settings

The one remaining niggle was that I had to switch to the main *.tex file every time I wanted to compile a LaTeX project. I solved this by changing the project settings. Open the project settings with Project > Edit Project, then add your main *.tex file as the value of the TEXroot setting:

		"TEXroot": "your-main-tex-file.tex"


With this set-up, the behaviour of WinEdt is replicated, in that I can compile the code from within the editor and view it automatically in a PDF viewer.

I’m a happy bunny once again.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.