To enable faster compilation of large documents I'd like to externalize tikz pictures. I also have to use lualatex and fontspec.

EDIT: After further testing it seems that this is a problem only when using MacTeX version of TeXLive.

The following minimal example fails to compile for me unless I comment out fontspec

%Comment the following line to get this to work!
  \pgfplotsset{plot coordinates/math parser=false}

\tikzset{external/system call={lualatex
    \tikzexternalcheckshellescape -halt-on-error
    -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzexternalize[shell escape=-enable-write18]

      scale only axis,xmin=1,xmax=3,ymin=1,ymax=6,name=plot]
      table[row sep=crcr]{
        1 2\\
        3 4\\
        5 6\\

Error message is:

===== 'mode=convert with system call': Invoking 'lualatex -halt-on-error 
-interaction=batchmode -jobname "main2-figure0" "\def\tikzexternalrealjob{main2}
\input{main2}"' ========
This is LuaTeX, Version beta-0.70.2-2012062819 (TeX Live 2012)
 restricted \write18 enabled.
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table

!LuaTeX error (file main2-figure0.pdf): xpdf: reading PDF image failed
 ==> Fatal error occurred, no output PDF file produced!

LaTeX exited abnormally with code 70 at Wed Apr  9 13:01:46

As suggested I've removed the externalization and added \listfiles which results in the following files:

This is LuaTeX, Version beta-0.76.0-2013061817 (rev 4627)  (format=lualatex 2014.4.10)  10 APR 2014 12:30    
\write18 enabled.    

*File List*
article.cls    2007/10/19 v1.4h Standard LaTeX document class
size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
fontspec.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
expl3.sty    2012/02/08 v3343 L3 Experimental code bundle wrapper
l3names.sty    2011/12/30 v3113 L3 Experimental namespace for primitives
l3bootstrap.sty    2011/12/29 v3110 L3 Experimental bootstrap code
luatex.sty    2010/03/09 v0.4 LuaTeX basic definition package (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
luatex-loader.sty    2010/03/09 v0.4 Lua module loader (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
color.sty    1999/02/16
color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
l3basics.sty    2012/02/06 v3317 L3 Experimental basic definitions
l3expan.sty    2012/01/15 v3196 L3 Experimental argument expansion
l3tl.sty    2012/02/06 v3316 L3 Experimental token lists
l3seq.sty    2012/01/09 v3158 L3 Experimental sequences and stacks
l3int.sty    2012/02/06 v3315 L3 Experimental integers
l3quark.sty    2012/01/08 v3148 L3 Experimental quarks
l3prg.sty    2012/02/08 v3338 L3 Experimental control structures
l3clist.sty    2012/01/09 v3157 L3 Experimental comma separated lists
l3token.sty    2012/02/06 v3316 L3 Experimental token manipulation
l3prop.sty    2012/01/09 v3158 L3 Experimental property lists
l3msg.sty    2012/02/06 v3316 L3 Experimental messages
l3io.sty    2012/01/28 v3245 L3 Experimental input-output operations
l3file.sty    2012/01/31 v3287 L3 Experimental file operations
l3skip.sty    2012/02/06 v3313 L3 Experimental dimensions and skips
l3keys.sty    2011/12/22 v3086 L3 Experimental key-value interfaces
l3fp.sty    2012/02/06 v3315 L3 Experimental floating-point operations
l3box.sty    2012/01/09 v3158 L3 Experimental boxes
l3coffins.sty    2012/01/08 v3155 L3 Experimental coffin code layer
l3color.sty    2011/09/07 v2776 L3 Experimental colour support
l3luatex.sty    2012/01/09 v3158 L3 Experimental LuaTeX-specific functions
xparse.sty    2012/02/08 v3342 L3 Experimental document command parser
luaotfload.sty    2014/02/05 v2.4-3 OpenType layout system
luatexbase.sty    2013/05/11 v0.6 Resource management for the LuaTeX macro progr
luatexbase-compat.sty    2011/05/24 v0.4 Compatibility tools for LuaTeX
luatexbase-modutils.sty    2013/05/11 v0.6 Module utilities for LuaTeX
luatexbase-loader.sty    2013/05/11 v0.6 Lua module loader for LuaTeX
luatexbase-regs.sty    2011/05/24 v0.4 Registers allocation for LuaTeX
luatexbase-attr.sty    2013/05/11 v0.6 Attributes allocation for LuaTeX
luatexbase-cctb.sty    2013/05/11 v0.6 Catcodetable allocation for LuaTeX
luatexbase-mcb.sty    2013/05/11 v0.6 Callback management for LuaTeX
fontspec-patches.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX

fixltx2e.sty    2006/09/13 v1.1m fixes to LaTeX
fontspec-luatex.sty    2013/05/20 v2.3c Font selection for XeLaTeX and LuaLaTeX
eu2enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
eu2lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many othe
r characters in Unicode lower plane
eu2lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
pgfplots.sty    2012/10/26 v1.7 Data Visualization (1.7-2-ge24fff4)
tikz.sty    2010/10/13 v2.10 (rcs-revision 1.76)
pgf.sty    2008/01/15 v2.10 (rcs-revision 1.12)
pgfrcs.sty    2010/10/25 v2.10 (rcs-revision 1.24)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
pgfcore.sty    2010/04/11 v2.10 (rcs-revision 1.7)
pgfsys.sty    2010/06/30 v2.10 (rcs-revision 1.37)
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
pgfcomp-version-0-65.sty    2007/07/03 v2.10 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v2.10 (rcs-revision 1.1)
pgffor.sty    2010/03/23 v2.10 (rcs-revision 1.18)
t3cmr.fd    2001/12/31 TIPA font definitions
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
  • I compiled your MWE with Texmaker on Ubuntu 14.04 with TexLive2013. First compile with XeLaTeX then compile with LuaLaTeX. Everything is OK.
    – user31034
    Apr 10, 2014 at 10:57
  • That is interesting. I tried XeLaTeX which works! However, did you delete the file main2-figure0.pdfbefore recompiling with lualatex. The problem is that LuaLaTeX cannot produce that file. If it is already produced with e.g. XeLaTeX, then LuaLaTeX can compile fine since it doesn't go through the external-procedure!
    – DrJay
    Apr 10, 2014 at 11:04
  • I can confirm the problem for TL 2014 on Windows 7.
    – henry
    Aug 7, 2014 at 19:45
  • Ok... update: I found the error, which was actually unrelated to the setup of LuaLaTeX, fontspec and pgfplots (typo when specifying the line width :/). Having said that: the little things can be SO annoying sometimes. Never forget to check the .log files which get created for each externalized TikZ environment... :)
    – henry
    Aug 7, 2014 at 20:03

1 Answer 1


The problem is caused by your placement of \tikzexternalize. Older versions of pgf would allow this in both the preamble and document body, although this was not documented. With the v3 update, it now has to appear in the preamble: what you are actually seeing is a failure in the main job after the auxiliary job aborts. (The error message is clearer with pdfLaTeX.) Remove \tikzexternalize after \begin{document}, and if you need to selectively turn externalization on/off use \tikzexternalenable/\tikzexternaldisable.

  • Sorry! I've already tried what you suggest (and retried). It still does not compile.
    – DrJay
    Apr 9, 2014 at 11:20
  • @DrJay Could you edit in to your question a file list (add \listfiles to your input, skip the externalization entirely and find the file list in the .log file). I have a pretty up-to-date system and removing the \tikzexternalize after \begin{figure} does work for me.
    – Joseph Wright
    Apr 9, 2014 at 11:25
  • OK. I have added the filelist in my question.
    – DrJay
    Apr 9, 2014 at 11:35
  • I also tried my example on a computer with a completely updated TexLive2013. Errors persist!
    – DrJay
    Apr 9, 2014 at 12:15
  • @DrJay I have no issue with an up-to-date TL2013: please edit in the \listfiles output from this system into the question.
    – Joseph Wright
    Apr 9, 2014 at 12:46

You must log in to answer this question.

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