I am trying to externalize tikz plots using lualatex while encapsulating the whole tex file with pdflatex. I still couldn't figure out why this method is not working. I am using miktex and texstudio. calling pdflatex by:

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

where texstudio replaces % with filename to be processed.

I have a matlab plot given below, that is converted to tikz. Let's call it myfile.tikz:

scale only axis,
\addplot [
table[row sep=crcr]{
1 2\\
2 4\\
3 6\\


A minimal example using tikz would be:

\usepackage{pgfplots} % to use tikz graphics as given in http://www.mathworks.com/matlabcentral/fileexchange/22022-matlab2tikz
  \pgfplotsset{plot coordinates/math parser=false}
\tikzexternalize[prefix=tikz/,shell escape=-enable-write18]
\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}


I am getting the following error:

! Package tikz Error: Sorry, the system call 'lualatex -enable-write18 -halt-on
-error -interaction=batchmode -jobname "tikz/example-figure0" "\def\tikzexterna
lrealjob{example}\input{example}"' did NOT result in a usable output file 'tikz
/example-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that y
ou have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. S
ometimes it is also named 'write 18' or something like that. Or maybe the comma
nd simply failed? Error messages can be found in 'tikz/example-figure0.log'. If
 you continue now, I'll try to typeset the picture.
  • I found out that this issue may sometimes be related to many figures tried to be compiled. Latex is actually barfing for an issue where it cannot put all the picture to the correct places. Error is: Too many unprocessed floats
    – Ali
    Aug 24, 2014 at 23:31
  • 1
    That's a different error. The question is: what is the error in tikz/example-figure0.log. I suspect you'll say that file does not exist and I suspect that you will also say that tikz/ is not created. But that's expected. Externalisation won't create a directory, so if that's required by your system call, you must create it prior to compilation or externalisation will fail.
    – cfr
    Jul 14, 2017 at 18:45
  • 1
    Note that the error above is almost certainly not trying to include most of the figures in your document because they are optimised away. Hence, it is very unlikely that too many unprocessed floats would cause the externalisation to fail. (Not impossible, but not likely.) Moreover, if there are too many unprocessed floats, this problem will apply even if you don't externalise. For the externalisation itself, there are no floats really to place: it is only outputting the single image to a single (cropped) PDF.
    – cfr
    Jul 14, 2017 at 18:48

1 Answer 1


This works for me

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

The only other thing I am doing is to have write18 enabled in my pdflatex call so pdflatex can call lualatex. Works fine also with large data, but it is painfully slow.

Also if there is an error in the plot you have to check the individual log file. My editor (TexnicCenter) is not smart enough to jump to that log file so I have to go to the folder where the plot is located, open the log and check what went wrong....

  • since tikz folder is not generated, i cannot look into .log file. When you comment out the lua external, figure does not create any error.
    – Ali
    Nov 23, 2013 at 1:15
  • 1) pdflatex.exe" -synctex=1 -interaction=nonstopmode -enable-write18 "example".tex does still gives me the same error. 2) it strangely produces the pdf. 3) the log reports the error. 4) when i create tikz folder, it runs without any problem.
    – Ali
    Nov 23, 2013 at 1:42
  • This should be the accepted answer, There is an upper limit to the amount of memory that LaTeX can use and for very large TikZ files luaLaTeX is the only option. Feb 11, 2014 at 21:15
  • @cameron.bracken That makes no sense. The question used lualatex for the externalised images to begin with.
    – cfr
    Jul 14, 2017 at 18:40
  • 2
    @Ali Externalisation will never create the directory for you unless you made it part of the system call, I suppose. So if you use prefix=tikz/, a sub-directory tikz of the working directory must already exist. That is, you must create it prior to externalisation. Otherwise, the requested file cannot be written and externalisation will fail.
    – cfr
    Jul 14, 2017 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.