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?

3 Answers 3


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 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.

  • 12
    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'
    Commented Feb 22, 2013 at 18:31
  • 3
    @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
    Commented Feb 22, 2013 at 18:47
  • I use TexMaker and never heard about TexStudio. I searched about how to upgrade to TexStudio from TexMaker but it seems that I have to download the first one rather than upgrade from the last one, isn't it ? Commented Jul 31, 2017 at 11:50
  • @Marine1, TexStudio was a fork of TexMaker. You have to download and install each one separately.
    – hpesoj626
    Commented Aug 3, 2017 at 7:21
  • I still get errors because Pygments is not installed. How can I install that in a virutalenv and have TeXStudio use it? I don't want to install it system-wide. Commented May 19, 2021 at 5:43

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
  • 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
    Commented Jan 25, 2014 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .