[Tex/LaTex] Why does tikzexternalize produce this error report

tikz-externaltikz-pgf

I have spent a lot of time trying to make TikZ externalize work (on MiKTeX2.9). So I tried to just run the first program using externalize from the TikZ PGF manual:

\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}

It runs perfectly and produces a pdf and opens the pdf (as my WinEdt 10.1 is configured to do) if I cut out the two lines

\usetikzlibrary{external}
\tikzexternalize % activate!

But with those two it generates

! Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error
-interact ion=batchmode -jobname "MWE-figure0" "\def\tikzexternalrealjob{MWE}\input{MWE}" ' did NOT result in a
usable output file 'MWE-figure0' (expected one of .pdf:.j
pg:.jpeg:.png:). Please verify that you have enabled system calls. For
pdflatex , this is 'pdflatex -shell-escape'. Sometimes it is also
named 'write 18' or so mething like that. Or maybe the command simply
failed? Error messages can be fo und in 'MWE-figure0.log'. If you
continue now, I'll try to typeset the picture.

Is this a real problem? And if so, how can I avoid it?

It seems to be a real problem. When I continue (by entering q) then it actually does produce a pdf but does not open it. And it reports

Sorry, but texify.exe did not succeed.

I am not able to make externalize work after that. But I do not know what other mistakes I might be making. And I do not want to explore those any further until I understand this one.

Best Answer

Warning: Several threads on TeX StackExchange and elsewhere identify write18 as a security risk. The fullest discussion I found is several years old at

What analysis of Texlive's restricted permissions model exists?

I do not understand these issues but I can see that experts who do understand them did not agree on the risk. So I will not leave the switch -enable-write18 in my PDFLaTeX, though TikZexternalize will not work without it.

Using MiKTeX with WinEdt, you can make the program quoted from the TikZ manual above work by going to Options, Execution modes, PDFLaTeX, and entering

-enable-write18

in switches. I do not know if there is any reason you could not as well do it by adding this to switches for PDFTeXify or others.

However, when it works this way, it does require that the file name have no space. For example the file name

Revision on conjugation

will prevent compiling. Use instead

Revision_on_conjugation

Related Question