Dr.

# Sublime Text 3: use latexmk with ‚-shell-escape‘

Not only me, but also Andi spent an awful lot of time on this issue: get Sublime Text 3 (with LaTeXTools) to compile a LaTeX document with the -shell-escape option. The option enables shell execution of programs from within pdflatex to include external programs. We needed that for the minted package which supplies syntax highlighting to code blocks by accessing the Pygments library. But other LaTeX plugins require -shell-escape as well, so here is how we got it running:

Edit the file

and look for the definition of DEFAULT_COMMAND_LATEXMK. Add an -shell-escape after the %E so that the definition looks like:

DEFAULT_COMMAND_LATEXMK = ["latexmk", "-cd",
"-e", "\$pdflatex = '%E -shell-escape -interaction=nonstopmode -synctex=1 %S %O'",
"-f", "-pdf"]

After this change, restart Sublime Text 3. This is not a good solution because it alters the plugin and might get overwritten with a future update. But at least it runs. Credits go to Andi for finding this.

## Bonus: minted and memoir

As a bonus, I got an additional error when trying to compile the document with both minted and memoir packages enabled:

usr/local/texlive/2014/texmf-dist/tex/latex/float/float.sty:68: LaTeX Error: Command \newfloat already defined. [      {}}}]

I don’t exactly know what is going on here, but apparently it’s a conflict between these two packages1. My quick’n’dirty hack is the following:

\let\newfloat\undefined
\usepackage{minted}

Solution from this discussion.

1. Or maybe another one and minted, but who knows. (La)TeX is this »special« language amongst the programming languages which get’s sulky sometimes for no obvious reason. []