[Tex/LaTex] Why it gives an error when using \ tikzexternalize

externalizetikz-pgf

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.

PS: taken from How to properly include tikz pictures in other tex files?

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.

enter image description here

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

enter image description here

Edited 2

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

enter image description here

enter image description here

Best 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.