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

The following code from the pgf manual compiles fine with lualatex --shell-escape

A simple image is \tikz \fill (0,0) circle(5pt);.

But, if I write some luacode (for example $\pi = \directlua{tex.sprint(math.pi)}$) I have the following error message :

===== 'mode=convert with system call': Invoking 'pdflatex -halt-on-error -inter
action=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob{test}\input{
test}"' ========
runsystem(pdflatex -halt-on-error -interaction=batchmode -jobname "test-figure0
" "\def\tikzexternalrealjob{test}\input{test}")...executed.
./test.tex:7: Package tikz Error: Sorry, the system call 'pdflatex -halt-on-err
or -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob{tes
t}\input{test}"' did NOT result in a usable output file 'test-figure0' (expecte
d one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system cal
ls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 
'write 18' or something like that. Or maybe the command simply failed? Error me
ssages can be found in 'test-figure0.log'. If you continue now, I'll try to typ
eset the picture.

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

l.7 ...ple image is \tikz \fill (0,0) circle(5pt);

The question is: what's wrong? And subsidiarily, why is pdflatex invoked?

N.B. The compilation with lua code fails only if I deleted the aux files before.

share|improve this question
up vote 16 down vote accepted

You can change the program PGF/TikZ calls to generate the external graphics with the key /tikz/external/system call (see the manual, page 345). The default value is

\tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}

Replacing pdflatex with lualatex should solve the problem:

\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
A simple image is \tikz \fill (0,0) circle(5pt);.
$\pi = \directlua{tex.sprint(math.pi)}$
share|improve this answer
This just saved my day. The problem still persists in pgfplots 1.7. Thanks. – Ingo Feb 13 '13 at 9:55
This isn't working for me, and lualatex --help shows that it uses double-hyphen for options, but even fixing that doesn't help. Any extra troubleshooting steps needed? I have TexWorks and MiKTeX 2.9. – Ben Voigt Jan 1 '14 at 22:46
Ahh, spaces in the filename of the master document are particularly problematic for lualatex (moreso than pdflatex, anyway) – Ben Voigt Jan 1 '14 at 23:03

It seems that what is wrong is exactly that pdflatex is called. It does not understand \directlua, and therefore cannot produce your external graphics.

The reason that pdflatex is calls seems to be that it is hardcoded in the /tex/generic/pgf/frontendlayer/tikz/libraries/tikzexternalshared.code.tex file. Try to edit that file, and replace each call to pdflatex by lualatex. Hopefully that will help.

share|improve this answer
Seems to be best to write a bug report for PGF/TikZ then. – Martin Scharrer Mar 2 '11 at 6:42

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.