# tikzexternalize only (or not) for flagged graphics

I have a couple of pictures in my work so I started to build them extern in order to increase build speed. But I don't want to externalize all of them, I want a few little pictures to be build on-the-fly.

I found an interesting changelog on sourceforge (maybe the source code for a manual) where it says

how to disable the externalization partially with |\tikzset{external/|\declareandlabel{export}|=false}| or completely with |\tikzexternaldisable|,

but that didn' work for me. I activate externalization with

\tikzexternalize[prefix=figures/,figure list=true]


so what kind of command could either externalize only flagged graphics or prevent flagged graphics from being externalized?

There are a couple of ways to turn on and off the externalisation stuff. To globally switch it off, use

\tikzexternaldisable


and then to turn it back on again,

\tikzexternalenable


An alternative way of doing that is to use

\tikzset{external/export=false}


and

\tikzset{external/export=true}


These two methods use slightly different ways of disabling: the second is "lighter" than the first.

To disable externalisation for an individual picture, use

\tikzset{external/export next=false}


One thing to be ware of when enabling/disabling externalisation is that if you don't name the pictures explicitly then they are assigned names in numerical sequence. This means that if you put a new picture in the middle (or enable/disable externalisation for one in the middle) then all the following ones will be out of sequence. But TikZ won't know that so you have to tell it yourself (the easiest way is by deleting the relevant image files).

A quick experiment shows that if you want to externalise most but to switch it off for one or two, then use the \tikzset{external/export next=false} command just before.

If you want to externalise only one or two, then you need to switch it on just before and off again just after (using one of the two methods given above). It seems that if it is disabled using \tikzset{external/export=false} then it cannot be turned back on for a single picture using \tikzset{external/export next=true} (which would have been nice).

• The "To globally switch it off, use" is not technically correct, is it? \tikzexternaldisable is locally scoped, isn't it? May 3 '12 at 22:16

As an alternative to switching TikZ externalization off and on again, I ended up with using

\usetikzlibrary{external}
\tikzexternalize % activate!
\tikzset{external/only named=true}


and manually enabling externalization for heavy plots/graphics only using

\tikzsetnextfilename{myfigure}% (use % to avoid additional whitespace)
\begin{tikzpicture}
...
\end{tikzpicture}


This is especially helpful in LaTeX beamer if externalization would break \only animations and you don't feel like creating a cache file for every overlay.