Why it gives an error when using \ tikzexternalize?

The message "Package tikz Error: Sorry, the system call 'pdflatex -hell-escape -halt-on-e" appears when I compile with pdflatex and also when I compile with pdflatex-shell-escape.

If I remove \ tikzexternalize from the preamble it compiles correctly, but where I know it must be used if one wishes to include tikz images in other text files. Which function has exactly \ tikzexternalize because this case does not need to be used.

Main file

\documentclass{book}
\usepackage{pgf}
\usepackage{tikz}

\usetikzlibrary{shapes,external}
\tikzexternalize

\usepackage{lipsum}

\tikzset{naming/.style={align=center,font=\footnotesize}}
\tikzset{area/.style = {draw, shape = regular polygon, regular polygon sides = 10, thick, minimum width = 5cm}}

\begin{document}
\lipsum[1]

\input{tikzcode}

\lipsum[2]

\end{document}


Simplified file (tikzcode)

\begin{figure}[htb]
\centering
\begin{tikzpicture}[font=\footnotesize]
\node [area] at (0,0) (cell1) {};
\end{tikzpicture}
\caption{test}
\label{fig:test}
\end{figure}


Edited:

Correct has a space after pdflatex (see image 1) the configuration is for TeXstudio in MikTex.

In the image 2 the error appears but it produces the document.

Edited 2

Here are the two images compiled with pdflatex -shell-escape

• I just double checked and used precisely pdflatex -synctex=1 -interaction=nonstopmode -shell-escape, and there is no error on my machine. Of course, I do not question that you get an error, but I cannot reproduce it. – marmot Dec 3 '18 at 2:34
• Add ESCAPE: \the\pdfshellescape  to your document (and comment the picture), compile with your --shell-escape call and tell us what you get as output. – Ulrike Fischer Dec 3 '18 at 8:14
• @Ulrike Fischer Excuse my ignorance, [ESCAPE: \the\pdfshellescape] I add it before begin {document} or after it? or did not understand correctly? – Samuel Diaz Dec 3 '18 at 15:35
• Try it out. One of the two possibilities is wrong and will led to an error. – Ulrike Fischer Dec 3 '18 at 15:42
• There is no error in the log. Close texstudio and restart. If it stills shows an error, complain at the texstudio issue tracker. And better don't use spaces in file names. – Ulrike Fischer Dec 3 '18 at 17:11

1 Answer

not sure if you where able to fix this, but I ran into the same problem and noticed the following:

1. The only reason why the image is generated even though you see the error is because you have the pdf created already. If you delete everything (except tour .tex file) and run again, the error will result in nothing being generated.
2. The externalize function creates a bunch of pdf files for each tikzpicture. This depends on many things, such as markers for example, so if you are redoing one image, you might need to delete several pdf files in the external folder where they are being created (which is a pain since you can only be sure of the name you are giving to the main image file). If you don't do so, you'll encounter the error you mention.
3. The other reason why I encounter the same error is because when I reopened texstudio, the compilation command had reverted back to normal (i.e. "-shell-escape" was not there).

Hopefully some of this comments help you.