[Tex/LaTex] How to enable shell escape when building with latexmk and xelatex

latexmkshell-escapexetex

The title already says the question.

I want to clarify that this is not a duplicate, because existing answers are all for plain latex or pdflatex. Building with latexmk and pdflatex with shell escape can be done with latexmk -latex="latex -shell-escape and latexmk -pdflatex="pdflatex -shell-escape, but we cannot change the full command arguments used for xelatex when invoking latexmk -xelatex.

Best Answer

There are multiple options:

  • latexmk -xelatex -latexoption="-shell-escape" document

  • latexmk -xelatex -shell-escape document (this option is not listed in the normal latexmk -help menu, but you have to run latexmk -showextraoptions to see it)