[Tex/LaTex] Using \tikzexternalize


I want to use tikzexternalize in my document, because the amount of tikz pictures is quite large. In general my tikz pictures are generated using matlab2tikz providing every tikz picture as a standalone. For the example the main document looks like this:

\pgfplotsset{/pgf/number format/use comma}
\tikzexternalize % activate!

Within the file fig_01 the following simplified code was generated using matlab2tikz:


\draw (2,2) ellipse (3cm and 1cm);

While excluding lines 7 and 8 from the main the compilation works fine – not so with the externalization activated.

My compilation command for pdflatex within TexStudio is:

"/usr/local/texlive/2015/bin/universal-darwin/pdflatex" -synctex=1 -interaction=nonstopmode %.tex

Best Answer

Externalisation relies on 'shell escape'. When this is restricted or disabled, externalisation can't work because it requires the compiler to spawn additional compilation commands in order to create each picture separately.

By default, this feature is disabled for security reasons. A restricted set of commands may be spawned, but this set is not sufficient for the compilation of the pictures.

Hence, you need to override the default setting by explicitly allowing unrestricted shell escape for the compilation:

"/usr/local/texlive/2015/bin/universal-darwin/pdflatex" -synctex=1 -interaction=nonstopmode -shell-escape