Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}

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

2 Answers 2

up vote 15 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:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzexternalize
\begin{document}
A simple image is \tikz \fill (0,0) circle(5pt);.
$\pi = \directlua{tex.sprint(math.pi)}$
\end{document}
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 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 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
4  
Seems to be best to write a bug report for PGF/TikZ then. –  Martin Scharrer Mar 2 '11 at 6:42

Your Answer

 
discard

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.