LaTeX tikz externalize to reduce memory usage and cache figures

A trick to reduce the memory usage of LaTeX (instead or in addition to increase LaTeX’s memory as shown in my previous post) and to reduce build times for large documents with many tikz figures is to use tikzexternalize. I add the following lines to my document definition:

\usepackage{tikz}               % all my graphs and some hand tikz'd
\usetikzlibrary{patterns}
\usetikzlibrary{external}
\tikzexternalize[prefix=./]

Note that now many packets need to be wrapped into code that disables and re-enables externalising again, e.g., the todo package:

\newcommand{\xtodo}[2][]{\tikzexternaldisable\todo[#1]{#2}\tikzexternalenable}

or the missing figure command of the same package:

\newcommand{\xmissingfigure}[2][]{\tikzexternaldisable\missingfigure[#1]{#2}\tikzexternalenable}

Due to this side effect I would only recommend to use tikzexternalize when in urgent need, i.e., the document build times are unbearable.

That’s it again!
Cheers,
iss