Type-setting from within ST3

For all the years I’ve been using Sublime Text to write my reports in LaTeX, creating a build system had escaped my list of to-dos. Build systems are handy: they enable building (compiling, type-setting) from within Sublime Text. Here are a couple of steps for MacOS:

  1. Select Tools > Build System > New Build System… and replace the entire pre-populated JSON instruction with the following:

        "cmd": ["/usr/local/texlive/2020basic/bin/x86_64-darwin/xelatex", 
        "selector": "text.tex.latex"

    To explain the above, I use xelatex as my type-setting system. Finding the path of xelatex is as easy as running a query at command line like so:

    $ which xelatex
  2. Save it as LaTeX.sublime-build. (It will be saved under the folder ~/Library/Application Support/Sublime Text 3/Packages/User/.)

  3. This above allows one to type-set (or build) by pressing + B.

A minor wrinkle with the build system is that unlike running xelatex from Terminal, building from within Sublime Text does not recognise artefacts (like class and style files) placed within ~/texmf folder, and so common resources require a full path. Following is an example. Note, e.g., ckunte.sty (style) file has been given a full path like so:


Same goes for any resource within ~/texmf/ckunte.sty. For instance, I use a custom pythonhighlight.sty within ~/texmf/ckunte.sty. That needs to have a full path as well:


I am still figuring out how to replicate this on a hybrid system on my work machine with Sublime Text as native app in Windows 10, while xelatex is only accessible via Cygwin. Worst case scenario, I will have to stick to my old ways, which is to write in Sublime Text, and type-set via command line.