# Externalize Tikz picture result in error 'pdflatex -holt-on-error but shell escape is used

I am trying to externalize tikz-picture by using the externalize library. I am using Miktex 2.9. I activate the external feature by using

\tikzexternalize


and also tried

\tikzexternalize[shell escape=-enable-write18]


I just use the command mentioned in the manual:

pdflatex -shell-escape main


and start this in the commandfunction of windwos inside the directory with the main.tex I even tried choosing the pdflatex.exe directly. At the beginning it seems fine, he creates main-figure0 files but then suddenly stopped with an error:

! Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error - interaction=batchmode -jobname "main-figure0" \def\tikzexternalrealjob{main}\input{main}" ' did NOT result in a usable output file 'main-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'.

The tikz-picture itseld seems to right as without externalize it is drawn since it just contains a

\draw (1,0) to (2,4);


Without externalize this compiles fine.

\documentclass[tikz]{standalone}

\usetikzlibrary{external}
\tikzexternalize

\begin{document}
hello
\begin{tikzpicture}
\draw (1,0) to (2,4);
\end{tikzpicture}
\end{document}


I used:

pdflatex -shell-escape external_test

figure0.log says at the end:

[1]
! Missing } inserted.
<inserted text>
}
l.12 \end{document}


Real structure of the project:

Main.tex
-> \documentclass{scrbook}
[...] usepackages
\externalize

\begin{document}
\input{standalone_file.tex}
\end{document}

standalone_file.tex
-> \documentclass[tikz]{standalone}
[...] usepackages

\begin{document}
[tikzpicure_environment]
\end{document}


Anyone an idea?

• To me, this setup looks strange. Do you really externalize from a standalone document? When using article with the respective usepackage it should work as intended. – TeXnician Aug 27 '18 at 11:27
• I don't quite get this: You are externalizing pictures that are in separate standalone files? Why not using one or the other version? This way seems very tricky for no additional benefit. – TeXnician Aug 27 '18 at 12:32
• I use the standalone_file just for creation of the picture to check if it looks right. At the end i have to compile the tikzpicture using the main_file to make sure all references and all fonts are the same. But i see you are right, i can just use the .pdf by using \includepicture – SRel Aug 27 '18 at 12:35
• Use \usepackage{tikz} instead of [tikz] and compile with pdflatex -shell-escape %. Then it should work. If you like to save your tikz figures in an extra folder you could use \tikzexternalize%[prefix=TikzPDFs/] with \tikzsetnextfilename{YourFileNameOfOutputA}before every tikzpicture. – Bobyandbob Sep 9 '18 at 12:19
• @SRel have you to tried it? Does it work for you too? – Bobyandbob Sep 30 '18 at 21:01