Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the externalize capability of TikZ (external library) to speed up compilation of my TikZ pictures (as explained in Script to automate externalizing tikz graphics).

In addition, I would like to speed up compilation by precompiling the preamble. It is explained in http://magic.aladdin.cs.cmu.edu/2007/11/02/precompiled-preamble-for-latex/ how this can be achieved. The command for precompiling the header is:

pdflatex -ini -job-name="main" "&pdflatex fmt.tex\dump"

where fmt.tex contains the documentclass and package declarations, and the header is subsequently inserted into the file by having the first line say

%&fmt

Both methods by themselves work well and result in nice speed-ups. Now, I am trying to apply both methods at the same time. This gives me the following error-message during compilation:

! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
    rror -interaction=batchmode -jobname "figures/fmt-figure0" "\def\tikzexternalre
    aljob{fmt}\input{fmt}"' did NOT result in a usable output file 'figures/fmt-fig
    ure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enab
    led 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 fa
    iled? Error messages can be found in 'figures/fmt-figure0.log'. If you continue
     now, I'll try to typeset the picture.

Note: I am compiling with option -shell-escape already. In addition, I precompiled the header with that option as well.

Minimal working (breaking) example:

fmt.tex - the header

\documentclass{article} 
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]

test.tex - the main file

%&fmt
\begin{document}
\begin{tikzpicture}
\node[draw, circle, minimum width=1cm] {};
\end{tikzpicture}
\end{document}
share|improve this question
    
Note that you can place links directly into questions and answers. You don't need to use the 'add link' button. The links look the same or even better: links to other stackexchange posts will be formatted automatically. –  Martin Scharrer Apr 27 '11 at 10:32
    
Maybe you need to move some of the TikZ code to the dynamic preamble. The guide you linked states that everything which loads auxiliary files must not be pre-compiled, so just move the external library from the static to the dynamic preamble. If this doesn't work please consider to add a minimal working example (MWE) that causes this error. Otherwise it will be difficult to fix it. –  Martin Scharrer Apr 27 '11 at 11:18
2  
I'm doing the exact same thing here, yet all is good. Note that my \tikzexternalize command is in my dynamic preamble. The library itself can be in the static preamble unlike with Martin said. –  romeovs Apr 27 '11 at 11:51
    
@remeovs: Thanks for sharing. I just meant to experiment with the position of the externalization code. Moving the library would just be the first step. –  Martin Scharrer Apr 27 '11 at 12:52
1  
Thanks guys. The problem was that \tikzexternalize was in the static preamble. –  and0rx0r Apr 27 '11 at 15:18
show 3 more comments

2 Answers 2

Add the \tikzexternalize command to the dynamic preamble and all will be good.

share|improve this answer
add comment

If you need the tikzexternalize to be called in the static preamble (for example if you have other macros relying on that), you can do one of the following :

  • name your format file after after the project jobname, either by running

    pdflatex -ini -job-name="<yourJobNameHere>" "&pdflatex fmt.tex\dump"
    

    or if you don't want to have to recompile the preamble each time you make a new project, by simply creating a symbolic link in your working directory, named yourJobNameHere.fmt, linking to the file main.fmt.

  • add in the dynamic preamble the following command :

    \renewcommand{\tikzexternaljobname}{yourJobNameHere}
    

Depending on the macros you need to write in the precompiled preamble, the second solution might lead to problems, though.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.