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:
\documentclass{article}
\usepackage{standalone}
\usepackage{pgfplots}
\pgfplotsset{/pgf/number format/use comma}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
%
\begin{figure}
\centering
\includestandalone[width=0.8\linewidth]{./fig_01}
\caption{mycaption}
\label{fig:01}
\end{figure}
%
\end{document}
Within the file fig_01
the following simplified code was generated using matlab2tikz
:
\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{grffile}
\pgfplotsset{compat=newest}
\usetikzlibrary{plotmarks}
\usepgfplotslibrary{patchplots}
\usepackage{amsmath}
\begin{document}
%
\begin{tikzpicture}
\draw (2,2) ellipse (3cm and 1cm);
\end{tikzpicture}%
\end{document}
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: