I haven't seen this asked specifically, though I have seen related questions.

I just installed the minted package and noticed I have to run latex/pdflatex with a command-line option, -shell-escape, for it to run. I can do that manually, of course, but what if I'm using latexmk?


If you need to do this just once, run:

latexmk -e '$latex=q/latex %O -shell-escape %S/'


latexmk -e '$pdflatex=q/pdflatex %O -shell-escape %S/' -pdf

for PDF output.

If you want latexmk to always run with this option enabled, you should put the following in your .latexmkrc file (yes, that's a thing):

$latex = 'latex  %O  --shell-escape %S';
$pdflatex = 'pdflatex  %O  --shell-escape %S';


Enabling --shell-escape by default is dangerous, since it makes the latex binary execute arbitrary shell commands in latex files.**

  • 1
    You can also consider creating a Makefile (or a script, be it bash or cmd), if you want to have --shell-escape on a per-project basis. – rubdos Jun 9 '17 at 17:26
  • 1
    What is q/ for? – bers Jun 28 at 9:11
  • The q/ is explained in the documentation as In this example, the q/.../ construct is a Perl idiom equivalent to single quotes. It is about escaping and proper quoting. – Hans Lollo Aug 9 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.