For the sake of speed and potential file size errors I have been trying to set up the externalization of pgfplots/tikz for my figures including/excluding luatex.

I have the following question which is unclear to me:

  • After externalization, should you call the figure from the pdf, or does tikz/pgf automatically determine if it should run the .tex file or if it should load the pdf?

It is giving me a few issues:

  • When externalizing using pdflatex, I get a memory exceedance error. Which is not produced with externalization switched of.
  • If externalization is performed all the way using lualatex, it still crashes when compiling with pdflatex afterwards.

I am not sure if this is a correct MWE:

Compile with either:

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

lualatex.exe -synctex=1 -shell-escape -interaction=nonstopmode %.tex

In the main document:


\tikzset{external/force remake}



A random tikz figure document (actually contains thousends of datapoints):

\addplot [color=black, forget plot]
0 0 \\
0.1 20\\
  • 1
    Welcome to TeX.SX! Could you add a MWE ? - Maybe helpful links... tikz externalization using lualatex, Script to automate externalizing TikZ, output-directory and tikzexternalize, using tikz externalize
    – Bobyandbob
    Commented Oct 30, 2017 at 11:02
  • Thank you, I am not completely sure if the MWE I have included is sufficient. Please let me know!
    – J Daamen
    Commented Oct 30, 2017 at 12:26
  • What should \tikzset{external/force remake} do? Do you only want to save your tikz image in the folder figures/? Is pdflatex okay?
    – Bobyandbob
    Commented Oct 30, 2017 at 14:07
  • \tikzset{external/force remake} should force pgf to re-externalize all figures. With or without this option, pdflatex gives the memory issue. Without any externalization is does not. Luatex works for all three. Though, it screws up many other functionalities in my file. Yes I want to save the images in <dir>/figures/.... How can I check if pdflatex is ok?
    – J Daamen
    Commented Oct 30, 2017 at 14:13
  • Your MWE does not compile(please check). Nevertheless a add an answer, i hope it works for you. If not please let me know.
    – Bobyandbob
    Commented Oct 30, 2017 at 14:26

1 Answer 1


I'm not sure if it get the problem. But you could try to compile with pdflatex:

pdflatex -shell-escape %

EDIT: Or with lualatex:

lualatex -shell-escape %

NOTE: For lualatex you nedd the package \usepackage{shellesc} (Ref. @UlrikeFischer)

Folder structure and result:

enter image description here



\usepackage{shellesc}% to compile with lualatex

\tikzset{external/force remake} %up-to-date checks of all following figures (see: 50.4.3 Remaking Figures or Skipping Figures in pgf manual)

%\pgfplotstableread[row sep=crcr]{
%0 0 \\
%5 20\\


\tikzsetnextfilename{SaveNameFigureOne}%image name

%\tikzsetnextfilename{TestImageTwo}%image name



\addplot [color=black, forget plot]table[row sep=crcr]{0 0 \\
0.1 20\\};
  • Ok this helped clear up a few things. The main problem is that I had a file which was apperently just a bit to large for pdflatex (few kbs). Though, it only gave errors when externalizing. Not when compiling in the normal slow mode. I wanted to fix this by externalizing with luatex. And afterwards run pdflatex so that it would not have to generate that file. Though, after looking at the logs this does not work. So I guess I will either have to make a switch to lualatex. Use the pdf for the spcific file instead. Or downsample further. Thanks for the help.
    – J Daamen
    Commented Oct 30, 2017 at 14:37
  • @JDaamen Okay sorry. So only the size is the problem? You could generate the tikz images with one main file (first) and then load the pdf images of them in the other main file.... Is this an option? Or could you specify your problem with an MWE?
    – Bobyandbob
    Commented Oct 30, 2017 at 14:43
  • 1
    Yes I think this is the most pragmatic solution at this moment. Sorry for the vague questioning. I am not so fluent with latex yet. But you helped me a lot in understanding and solved my problem. Thank you!
    – J Daamen
    Commented Oct 30, 2017 at 14:49
  • @JDaamen. I updated my answer. If you add \usepackage{shellesc}. You could compile with lualatex -shell-escape % instead of pdflatex -shell-escape %. Maybe it is helpful for you ...
    – Bobyandbob
    Commented Oct 30, 2017 at 15:55
  • @JDaamen does the solution with lualatex (see update) works for you? or do you have still trouble with lua?
    – Bobyandbob
    Commented Nov 20, 2017 at 22:07

You must log in to answer this question.

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