# How to run LuaLaTeX only for tikzexternalize while running PDFLaTeX? [closed]

When I run PDFLaTex when using \tikzexternalize, for large files I get an error that the TeX capacity is exceeded (enlarging does not help). However, when I compile with LuaLaTeX it works (for small tikz files, compiling with PDFLaTeX works fine). If I use \tikzexternaldisable for the large tikz files, then PDFLaTeX also works fine, but then no PDF of the figure is created. Now I want to compile with PDFLaTeX, and only compile the external tikz figures with LuaLaTeX, how can I realize this?

In my preamble is use:

\usepgfplotslibrary{external}
\tikzexternalize[prefix=Images/Tikz/]
\tikzexternalize[shell escape=-enable-write18]

\newcommand\includetikz[1]{
\tikzsetnextfilename{#1}
\filemodCmp{Images/#1.tex}{Images/Tikz//#1.log}%
{\tikzset{external/force remake=true}\input{Images/#1}}
{\input{Images/#1}}}


Then it is working when compiling with LuaLaTex. I added the following to my preamble to run my file with PDFLaTeX:

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


I also added --enable-write18 --shell-escape in the command line. Then I tried to run it with PDFLaTeX, but I still get the memory error. How to resolve this?

In my document I use the following to insert the figure (created with Matlab2tikz):

\begin{figure}[H]
\centering
\setlength\fheight{0.8\textwidth}
\setlength\fwidth{1\textwidth}
\includetikz{BodeMag}
\caption{}
\end{figure}


## closed as unclear what you're asking by user36296, Stefan Pinnow, TeXnician, Phelype Oleinik, Dai BowenMar 11 '18 at 14:20

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• The first step is to make a complete example that other can tests. Snippets are evil ... – Ulrike Fischer Aug 2 '17 at 8:15
• I find that creating a graph in a separate file using the standalone document class is more convenient than externalizing graphics. – JPi Aug 2 '17 at 9:46
• @UlrikeFischer The problem is that when I use a simple example, compiling with PDFLaTeX works fine. Only for large tikz files I have this problem. – Bas Aug 2 '17 at 10:00
• I didn't write "make a simple example" but "make a complete example". Such issues must be tested. So completeness is necessary, simplicity is a bonus. You could try to compile once with lualatex to get the pictures and then remove the external/force remake=true and fall back to pdflatex. – Ulrike Fischer Aug 2 '17 at 12:06