TransWikia.com

How to have latexmk always use -shell-escape?

TeX - LaTeX Asked on November 25, 2020

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?

3 Answers

You can pass the parameter directly to latexmk as such:

latexmk -shell-escape

This option is not mentioned in the manpage. The manpage suggests the -e option which is also used in the first answer. This option amongst many others can be found using

latexmk -showextraoptions

The command output starts with the following note:

List of extra latex and pdflatex options recognized by latexmk. These are passed as is to (pdf)latex. They may not be recognized by particular versions of (pdf)latex. [..]

Tested with latexmk versions

  • 1 January 2015. Version 4.41
  • 26 Dec. 2019, version: 4.67

Correct answer by snwflk on November 25, 2020

If you need to do this just once, run:

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

or

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';

Caveat!

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

Answered by einpoklum on November 25, 2020

To enable shell-escape for all *latex commands using a latexmkrc file:

set_tex_cmds( '--shell-escape %O %S' );

Answered by user35915 on November 25, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP