Is there a script to automate externalizing TikZ graphics?
(As suggested by Scott here)
The TikZ 2.10 library,
If your document is named
To compile the document, you will need to ensure the
A whole pile of options is available to customize the way the figures are output. See section 31.4 (this numbering is subject to change!) of the development version documentation for complete info and options. The manual also covers how to obtain EPS output- but this option looks less polished than PDF output.
I've made a shell script, which makes pdf's from all my tikz-pictures, but only if necessary, i.e. if the source is newer than an existing pdf.
As far as I see, my solution has the advantage to others, that the pdfs are compiled in parallel, but you get noticed if one or multiple pdfs fail to compile, and then the rest of the compilation stops.
So, I have got an .sty-file for the script-call like the following. There is a definition for the images-Folder, two example images and the script call and return value handling.
The image is included like this in a (very short) main document:
An example for an image would be
And the called shell script (which could easily be replaced by perhaps nicer solutions like the python script by pmav99) looks like the following:
When I was writing my MSc thesis, I had created all of my figures and diagrams with tikz and pgfplots (using matplotlib2tikz). Keeping all of them within the source was not acceptable, since the compilation was getting really slow, so I was searching for something that would allow me to automatically compile all those figures to pdf files that I could include in my text.
For various reasons, I was not entirely satisfied with any of the other solutions so I wrote a Python script that suited my purpose.
The things you must keep in mind are:
The script searches recursively within a folder structure for *.tikz files and compiles them using the specified preamble. Each time the scripts runs, it stores the modification time of each *.tikz file and on subsequent runs it compiles only the newly created files of the files that have been modified since the last run. If you make changes in your preamble, you just pass a command-line argument and it compiles all the *.tikz files.
On linux it works great. I haven't tested it on windows, but I don't see why it shouldn't run. Anyway, even if there is any problem, the fix is going to be really trivial
Here's my alternative; Konrad's answer is probably just as good, and certainly better documented.
I’ve just come up with the following. It seems to work quite well (on Unix/Linux and Mac):
Next, it invokes