0

This is a very special case, I guess, but it's what I need:

%&Testing
\documentclass{article}
\endofdump
\usepackage{pgfplots}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[xlabel=x axis label,ylabel=y axis label]
    \addplot {x};
    \end{axis}
    \end{tikzpicture}
\end{document}

I want to be able to switch tikz on or off without having to recompile the preamble, hence the \endofdump. I created the header using MiKTeX and

etex -job-name=Testing -initialize "&pdflatex" mylatexformat.ltx Testing.tex

When I then compile Testing.tex, I get this error message:

! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "Testing-figure0" "\def\tikzexternalrealjo
b{Testing}\input{Testing}"' did NOT result in a usable output file 'Testing-fig
ure0' (expected one of .pdf:.jpg:.jpeg:.png:).

Checking the respective log file (Testing-figure0.log), I find this:

! Undefined control sequence.
<recently read> \endofdump 

l.3 \endofdump

I was wondering how I could fix this. It seems that the externalized tikz job inputs the preamble, but does not use the custom format. Hence, it can't understand \endofdump.

I found that this works (this may already be the answer).

%&Testing
\documentclass{article}
\ifcsname tikzexternalrealjob\endcsname\else\endofdump\fi
\usepackage{pgfplots}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[xlabel=x axis label,ylabel=y axis label]
    \addplot {x};
    \end{axis}
    \end{tikzpicture}
\end{document}

Is there a better way to do this?

3

You can change the macro that contains the external pdflatex call to instead call

etex '&mylatexformat'

I needed the following commandline to make the format

etex --job-name=testing --ini "&pdflatex" mylatexformat.ltx testing.tex

once the format is made, add the following so tikz externalize uses it

\def\zzz#1 #2\relax{%
\expandafter\def\csname pgfk@/tikz/external/system call\endcsname{etex '&mylatexformat' #2}%
}

\expandafter\expandafter\expandafter\zzz\csname pgfk@/tikz/external/system call\endcsname\relax

so this runs without error

%&Testing
\documentclass{article}
\endofdump
\usepackage{pgfplots}
\usetikzlibrary{external}
\def\zzz#1 #2\relax{%
\expandafter\def\csname pgfk@/tikz/external/system call\endcsname{etex '&mylatexformat' #2}%
}

\expandafter\expandafter\expandafter\zzz\csname pgfk@/tikz/external/system call\endcsname\relax
\begin{document}

    \begin{tikzpicture}
    \begin{axis}[xlabel=x axis label,ylabel=y axis label]
    \addplot {x};
    \end{axis}
    \end{tikzpicture}
\end{document}
0

What about the generic \ifdefined\endofdump\endofdump\else\fi?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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