I would like my externalised figures to have prefixes reflecting the chapter in which they are from, but when I do:
\usetikzlibrary{external}
\tikzexternalize[prefix=TiKz/\value{chapter}]
\tikzexternalize
or
\usetikzlibrary{external}
\tikzexternalize[prefix=TiKz/\c@chapter]
\tikzexternalize
I get errors and the correct labels are not created.
So the question is:
What is the right way?
What other variables can we stick in there? (ie other than counters, what else can TiKz give us. It obviously has some idea of the filename of that contains the figure…)
How can the filename prefix be suppresed. TiKz does a great job of automagically putting the filename as prefix, but in some circumstances this is not so great, for example when using subfiles, and reusing the externalised figures in the master document.
Please note when I say filename I mean the .tex document that is being built by pdflatex. Not as in the many examples of .tikz include.
8)
Best Answer
The
external
library comes with two "templates" which make up the file name: the staticprefix
and a more dynamicfigure name
.In order to use chapter/section names, you can make use of
figure name
:Compiling this with
pdflatex -shell-escape P
results in the filesAlternatively, you can modify the
figure name
on your own by adding further suffixes. Personally, I have always used this approach and found it better to read. It looks likeand generates files
The syntax
\pgfkeys{<key name>/.add={<prefix>}{<suffix>}}
allows to modify keys which contain a string. It takes the current value and prepends<prefix>
and appends<suffix>
. Since the values of these assignments are valid until the end of the current group, we can use curly braces to control their start and end of life.