4

I have a large document (I'm using pdflatex with Eclispe and TeXlipse) with many (many) TikZ graphics (most of them math function plots). Hoping to reduce compilation time drastically, I read about using externalize in order to save the plots and not redo them every time. The problem is I'm using a book template (which I modified just aesthetically) and other commands that incidentally use the tikzpicture environment. When trying to compile, I get an error if tikzexternalize is activated:

\usepackage{pgfplots}
\usetikzlibrary{external} 
\tikzexternalize[prefix=tikz/]

If I comment this last line, I get no errors, but then again, no externalization occurs.

Without commenting it, I get an error on every user-defined environment of the template, even the chapter heads (the template redefines some \chapter related commands). The thing is, I don't care if those things are externalized (I don't even know if they can) because they are little things that require almost no calculation. But my function plots do require lots of calculations, and really slow down the compilation process. Another thing that may cause trouble is that since I'm using babel with spanish I had to define my own tikzpicture environment to avoid some issue with the '>' character. The new environment looks like this:

\newenvironment{tikzpict}[1][]
{\begin{tikzpicture}[#1]\selectlanguage{english}}
{\selectlanguage{spanish}\end{tikzpicture}}

The error message goes like this:

Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error -interaction=batchmode -jobname "tikz/document-figure0" "\def\tikzexternalrealjob{document}\input{document}"' did NOT result in a usable output file 'tikz/document-figure0' (expected one of .pdf:.jpg:.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 something like that. Or maybe the command simply failed? Error messages can be found in 'tikz/document-figure0.log'. If you continue now, I'll try to typeset the picture. \chapter*{Licencia} (followed by: \addcontentsline{toc}{chapter}{Licencia})

Is there a way to tell TikZ to externalize only some of the pictures? I don't mind having to add another command on every picture to externalize if it solves the issue. I'm not looking for a too-complex-and-fancy-solution, just something to get this going (I'd love the complex and fancy solution too, but it's not necessary).

As an example, I'll quote the chapter definition, but again, every environment that uses TikZ throws the same error (as if it was trying to externalize it but couldn't).

\newcommand{\thechapterimage}{}
\newcommand{\chapterimage}[1]{\renewcommand{\thechapterimage}{#1}}
\def\thechapter{\arabic{chapter}}
\def\@makechapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]

\node[anchor=north west,inner sep=0pt] at (0,0) {\includegraphics[width=\paperwidth]{\thechapterimage}};

%Commenting the 3 lines below removes the small contents box in the chapter heading
% \draw[fill=white,opacity=.6] (1cm,0) rectangle (8cm,-7cm);
% \node[anchor=north west] at (1cm,.25cm) {\parbox[t][8cm][t]{6.5cm}{\huge\bfseries\flushleft \printcontents{l}{1}{\setcounter{tocdepth}{2}}}};

\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,fill=white,fill opacity=.6,text opacity=1,draw=ocre,draw opacity=1,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{\thechapter\ ---\ #1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\def\@makeschapterhead#1{
\thispagestyle{empty}
{\centering \normalfont\sffamily
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\startcontents
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.north west)
{\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north west] at (-4pt,4pt) {\includegraphics[width=\paperwidth]{\thechapterimage}};
\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,fill=white,opacity=.7,inner sep=15.5pt]{\huge\sffamily\bfseries\textcolor{black}{\vphantom{plPQq}\makebox[22cm]{}}};
\draw[anchor=west] (5cm,-9cm) node [rounded corners=25pt,draw=ocre,line width=2pt,inner sep=15pt]{\huge\sffamily\bfseries\textcolor{black}{#1\vphantom{plPQq}\makebox[22cm]{}}};
\end{tikzpicture}};
\end{tikzpicture}}\par\vspace*{230\p@}
\fi
\fi
}
\makeatother

Thanks in advance.

closed as unclear what you're asking by Johannes_B, Henri Menke, egreg, Fran, Stefan Pinnow Aug 7 '16 at 9:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You hsave to enable --shell-escape while compiling. Did you? – user11232 Jan 13 '14 at 6:50
  • Yes. Nothing happened. I'm using Eclipse, went to Preferences>Texlipse>Bulder Settings. Then selected pdflatex program on the list and added --shell-escape to the commands and nothing changed... – Ewajs Jan 13 '14 at 6:56
  • Sorry, I don't know much of Eclipse. But the system call 'pdflatex -halt-on-error -interaction=batchmode -jobname "tikz/document-figure0" indicates that there is no --shell-escape. – user11232 Jan 13 '14 at 7:02
  • For what I've investigated what I did was OK (adding the command where I did), and did not solve the problem. I'll keep looking onto that. But I think it's coming from a different place, related to the template I'm using. I'll try making another document just with the graph to test this. – Ewajs Jan 13 '14 at 7:14
  • Are there any news here? – Johannes_B Oct 5 '15 at 18:36