Minted – How to Invoke LaTeX with the -shell-escape Flag in TeXStudio

mintedshell-escapetexstudio

This is a follow-up question on the post: Creating a table around a java script code highlighted using minted where invoking -shell-escape flag in TeXStudio is one of the two questions posted by the OP.

When running my document in TeXMakerX with minted package, I get the error

minted Error: You must invoke LaTeX with the `-shell-escape` flag

How can I invoke -shell-escape in TeXMakerX?

Best Answer

First of all, TeXMakerX is now TeXStudio. If you are still running TeXMakerX then it is advised that you upgrade to the latest version of TeXStudio.

minted uses Pygments of Python for the fancy coloring schemes. You need to invoke the -shell-escape option in order for LaTeX to allow Pygments to be used.

In TeXStudio, click on the following menu

Options > Configure TeXStudio > Commands

and change

pdflatex -synctex=1 -interaction=nonstopmode %.tex

into

pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex

Edit

As mentioned by tohecz in comment, it is better to make a separate command for this in TeXStudio for security reasons. You can do this by clicking

Options > Configure TeXStudio > Build

and in the User Commands box, click +Add button and add a name for your command in the first cell, say user:graphviz-pdflatex and the command txs:///pdflatex/[--shell-escape] in the second cell.

enter image description here

You can then see the command listed in the menu

Tools > User

enter image description here Click on the command to run.

Related Question