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

See the following MWE.

\usepackage{minted, tikz}
\tikzset{external/system call={%
    xelatex \tikzexternalcheckshellescape
    -halt-on-error -interaction=batchmode
    -jobname "\image" "\texsource"}}

  \draw (0,0) --(1,2);

If I try to compile this with the command

xelatex -shell-escape bug.tex

I get the following error

This is XeTeX, Version 3.1415926-2.2-0.9995.2 (TeX Live 2009/Debian)
entering extended mode

! Package tikz Error: Sorry, the system call 'xelatex -halt-on-error -interacti
on=batchmode -jobname "bug-figure0" "\def\tikzexternalrealjob{bug}\input{bug}"'
 did NOT result in a usable output file 'bug-figure0' (expected one of .pdf:.jp
g:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex,
 this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or som
ething like that. Or maybe the command simply failed? Error messages can be fou
nd in 'bug-figure0.log'. If you continue now, I'll try to typeset the picture.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.

l.15 \end{tikzpicture}


  1. Tested with Tex Live 2009 as packaged for Debian squeeze. The version of minted
    (which is not in Tex Live 2009) is v1.7 (current release).

  2. Removing any of \tikzexternalize, \usepackage{minted}, or the tikz picture
    makes the error go away.

  3. I found the magical incantation inside \tikzset when looking for a way to get tikz externalize to work with xelatex. It worked till I started using minted.

  4. xelatex is needed because of fontspec, and fontspec is needed
    because of Arial. Without \setmainfont{Arial} and \usepackage{fontspec}, the example compiles with

    pdflatex -shell-escape bug.tex

    Strangely, this is still uses xelatex somewhere because of the \tikzset thing
    I added.

  5. I was using Arial because of a journal's deranged requirement. I realised I
    don't need to use it, and hence don't need to use xelatex. Since pdflatex
    works fine with this example, the whole problem goes away for me. However, this
    still looks like a bug to me, so posting.

  6. The error is in the externalized file, which here defaults to bug-figure0. bug-figure0.log has

     ! Package minted Error: You must invoke LaTeX with the -shell-escape flag.

    It looks to me like minted and tikz externalize are colliding with each other for
    some reason here.

share|improve this question
up vote 7 down vote accepted

Maybe one reason for the unreadiness is your accept rate.

After you have run xelatex --shell-escape bug.tex the error message give the hint:

 Error messages can be found in 'bug-figure0.log'

In this file you find the following hint:

Package ifplatform Warning: 
    shell escape is disabled, so I can only detect \ifwindows.

! Package minted Error: You must invoke LaTeX with the -shell-escape flag.

This error shows that the option shell-escape wouldn't be inherit.

To avoid the error you must specify the /tikz/external/system call by --shell-escape

Here the example:

\usepackage{minted, tikz}
    external/system call={%
    xelatex \tikzexternalcheckshellescape
    -halt-on-error -interaction=batchmode --shell-escape
    -jobname "\image" "\texsource"}}

  \draw (0,0) --(1,2);
share|improve this answer
This doesn't work for me. Did you test it? If it had worked, I'd have asked why my previous version worked with pdflatex and not xelatex. – Faheem Mitha Dec 21 '11 at 8:30
@FaheemMitha: Yes it works on my system. ;-). I am using TeX Live 2011 well updated also with tlcontrib. – Marco Daniel Dec 21 '11 at 8:31
I was mistaken. This does work. The problem is that cut and paste messed up the quotation marks. Sorry about that. However, I'm still unclear why it does work. And since this extra option is not required for pdflatex, why is it needed here? Can you elaborate? The external/system call is what is externally called on the standalone pictures, right? So why the extra shell-escape ? Incidentally, I notice you are using --shell-escape, but -shell-escape. It seems that both of them work, but what is the difference if any? – Faheem Mitha Dec 21 '11 at 20:11
@FaheemMitha: The differences betwenn -- and - are described here. – Marco Daniel Dec 21 '11 at 20:38

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.