TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 18 down vote accepted

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


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


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 pdflatex -shell-escape and the command pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex in the second cell.

You can then see the command listed in the menu

Tools > User

Click on the command to run.

share|improve this answer
I would like to remark that it would be better to make a seperate Command for this, so that you don't use --shell-escape when you don't need it. There is a reason why it's not allowed by default (namely, security). – yo' Feb 22 '13 at 18:31
@tohecz thanks. I have updated my answer accordingly. There is a post somewhere where security threats about the use of -shell-escape was discussed but I can't seem to find it. – hpesoj626 Feb 22 '13 at 18:47

TeXstudio also provides a way for documents to define their own build commands directly with "magic" comments.

So you can set the "compile" command to pdflatex augmented with the shell-escape option by including the following comment in the document:

% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]

Or override the entire "pdflatex" command (which is not recommended as it also removes the path information) with

% !TeX TXS-program:pdflatex = pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex
share|improve this answer
This is a very nice feature, I just tried it, it gives a warning, then after you've accepted to run with shell-espace, it pastes something like this at the top of the document % !TeX document-id = {423bf6c7-2569-47e5-ab93-e858acbc02fa} – PatrickT Jan 25 '14 at 17:45

Another way of doing this, but on a per-document basis, is to use arara, which is a tool for automating compilation of (La)TeX files. arara is part of TeX Live 2012, but if you use MikTeX you have to install it manually.

To set up TeXStudio, add a new User command, as described in hpesoj626's answer, with the command

arara %.tex

In your document you have to add one or more rules defining which commands to run, as "magic" comments at the start of the file. To compile with pdflatex and shell escape enabled, add

% arara: pdflatex: {shell: true}

at the beginning of your .tex file, and compile with the user command you just created.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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