I am trying to set up a "user command" on TeXStudio with the purpose of compiling with shell-escape and the LaTeX -> DviPs -> Ps2Pdf cycle.

This is what I have done to get shell-escape to work and produce PDF output. [Edit: This section edited: see explanation below]

Method 1. In TeXStudio preferences -> Build -> User Commands:

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

See screenshot: top user command, the two lines above are entered from left to right.

enter image description here

Method 2. At the top of my document insert the line:

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

This line induces TeXStudio to request authorization to compile with shell-escape. This setup has so far worked for me to invoke shell-escape and produce PDF output "on the fly".

By analogy, I tried the following:

Method 1b. User Command:

latex --shell-escape: dvips : ps2pdf : view-pdf
latex -synctex=1 -interaction=nonstopmode --shell-escape %.tex: dvips -o %.ps %.dvi: ps2pdf %.ps

Method 2b. Top of document:

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

But that does not work. Am I on the right track?

To provide context: my purpose is to be able to compile the code shown here: Recreating a guilloche with TikZ. The code relies on the tkz-fct package and apparently requires the use of shell-escape but does not support pdflatex, suggesting that the latex -> dvips -> ps2pdf route is a natural one to try. And it is the route recommended in the tkz-fct manual.

How to set user commands in TexStudio? is a tex-stackexchange question with a link to the TeXStudio doc, which addresses related problems, but not this particular one head-on.

The TeXStudio documentation is here:


Edit: Explanation about my first edit. I initially wrote that I had been succesful with the following settings:

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

However, I had been running this command on documents that had this at the top:

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

And it turns out that this line overrules my user commands. This is stated explicitly in Harish Kumar's answer (thanks Harish!). Without this overruling line, my user command does not succesfully invoke shell-escape. However, replacing pdflatex with latexmk did invoke shell-escape without the overruling line. I have therefore edited my incorrect claim. Having said that, I do not know much about latexmk other than it seems to be working.

Epilogue: Read Harish Kumar's answer to see how to properly enter the commands. Another thing I have since discovered is that the spanner-shaped button allows you to select among existing commands and to combine several commands, in that way the proper separator will be added between commands. Lastly, if you read the various comments here you will see that one reason why I had a hard time getting this to work was because the LaTeX file I was trying to compile needs gnuplot and I didn't have gnuplot installed on my system, giving me the impression that my commands were not working when they were (after Harish's corrections they were working properly).

  • 1
    Patrick, latexmk --shell-escape in the first box is just a name for the user command. It has nothing more to do. What you type in the second box is the executable command. So in first box you can type any name.
    – user11232
    Commented Feb 17, 2014 at 13:44

1 Answer 1


If you use the line

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

at the top of the document, then you don't need any extra user command. Just compile it. Then texstudio will compile it with latex with --shell-escape (of course it will ask your permission) (even if the default build has pdflatex as the compiler) and dvi file is produced. Then you can run DVI2PS and in turn PS2PDF.

Now the question is - whether you would like to compile the document with three clicks or one click. If the latter, then define a new user command like the following:

  1. Type the name of the command in the first box (mine is user2: LaTex.DVIPS.PS2PDF) ( (user2: may be different for you).
  2. Type the command:

    latex --synctex=1 -interaction=nonstopmode --shell-escape %.tex | dvips -o %.ps %.dvi| ps2pdf %.ps

in the second box as in this picture:

enter image description here

Note that command separator is |, not :.

Now if you use user2: LaTex.DVIPS.PS2PDF to compile, you won't need that first line: % !TeX TXS-p....

I get this:

enter image description here

  • Thanks! It doesn't work for me. I have the latest version of TeXStudio and am on Mac OS X. Two questions, if I may: 1) There are 2 boxes, do you mind detailing what you have in each? I'm assuming the line you have above is for the second box, so what about the first box? 2) do you have % !TeX TXS-program:compile = txs:///latex/[--shell-escape] at the top of your document? I don't get any pdf produced, and I don't get the message entering extended mode. Thanks!
    – PatrickT
    Commented Feb 16, 2014 at 16:17
  • @PatrickT Your first box is wrong. See the update.
    – user11232
    Commented Feb 16, 2014 at 23:15
  • thanks, that's very thorough, great answer. Well, I must have something wrong in my system. I notice from the first user command that you're on Windows and MikTeX. I'm on Mac OS and TeXLive. Perhaps a difference there. I'll test your lines on Windows and Linux tomorrow and get back to you (it's bed time in my time zone). Thanks again!
    – PatrickT
    Commented Feb 16, 2014 at 23:40
  • 1
    @PatrickT Now I am on windows, but for texstudio and its macros, it shouldn't make any difference :) Good night
    – user11232
    Commented Feb 16, 2014 at 23:57
  • 1
    @PatrickT For the guilloche code, you will need gnuplot installed. Install it on windows too and it should work. Glad you could make it :)
    – user11232
    Commented Feb 17, 2014 at 22:24

You must log in to answer this question.

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