I am plotting data from an infrared camera with pgfplots in an image as discribed and solved under this topic. A 194x194 data matrix is the input.

I am compiling the document with lualatex through pdflatex with in my header file through:

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

I also added


in the command for pdflatex.

This all works pretty well and the result from above link shows up. However, if I want to include another such picture with different data (or also with same), I'm running into errors

Syntax Error: Couldn't finf trailer dictionary Syntax Error: Couldn't read xref table

In my tikz-folder, where the externalized data are stored, all the files including the pdf are created. However, when trying to open the pdf-file, I get an error from Acrobat Reader that the file is damaged.

In the log file of the picture I find the following message:

("X:/Dropbox/2015 Dissertation/02 Documents/Dissertation_Template/pictures/temp 1c50DOD.tikz.tex" A tikzpicture has been optimized away. Use '/tikz/external/optimize=false' to di sable this. ) ("X:/Dropbox/2015 Dissertation/02 Documents/Dissertation_Template/pictures/temp 1c0DOD.tikz.tex" PGFPlots: reading {pictures/test2.txt} \tikzexternal@dep@file=\write9 [6

  • The message "A Tikzpicture has been optimized away" is purely informative. It indicates expected behavior, and disabling the optimization will effectively increase the time for externalizations unnecessarily and drastically. Commented Jul 22, 2015 at 9:00
  • That said, one of the involved files appears to be corrupt for some reason. I recommend to rebuild all external files (i.e. delete the externalized files, rerun the externalization). This will hopefully result in a useful error message. Please show that error message such that we can identify the root cause. Commented Jul 22, 2015 at 9:01
  • The problem is that the file gets corrupted during compilation. Deleting all files leads into the same error during compilation over and over again. And the error message doesn't get more useful unfortunately. I assume it's some problem that lualatex and tikzexternalize have with each other that leads to that error. The only way it could be fixed was the optimize=false option. Yes, it takes ages.
    – nmy2015
    Commented Jul 23, 2015 at 3:11
  • Ok. I would still assume that one of the external files was compiled incompletely and wrong, meaning that one of the externalization log files contains an error message -- probably the one that failed to be included. There are no known issues when using tikzexternalize with lualatex. I see two ways to go from here: (a) you post a minimal working example such that we can reproduce the problem and/or (b) you search all .log files for error messages. The best would be (a) if that is possible. There is no way to assist you without more information. Commented Jul 26, 2015 at 9:11
  • Hi Christian, the full code for what I'm doing is under the topic linked in my question above. The problem only exists with a large amount of data (One of the plots has 37636 data points in the background. The only error that was stated in any of the log files is the one I posted above, namely the one that states that tikzpicture has been optimized away.
    – nmy2015
    Commented Jul 27, 2015 at 2:23

1 Answer 1


After discussions with Christian (many thanks!!) and many different error messages that I received, two things helped finally to solve the problem:

  • Update ALL packages
  • inputenc doesn't work together with lualatex and leads to not compiling the external files. Removing this package helped.

You must log in to answer this question.

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