I am using the external library to avoid recompiling tikz figures unnecessarily in a large document. Every now and then I have to change some details of some selected pictures. After the modifications it is necessary to recompile only those figures that have been modified. My aim is to do that automatically.

From Christian Feuersänger's answer to this question, I have interpreted that pictures whose content change can be remade automatically. I have not found however a simple MWE in which a tikz figure is recompiled only when its content is changed. It would be useful to have one.

The following MWE does not work, in the sense that changes in figure.tikz do not trigger re-compilation of the figure.




\draw (0,0) -- (1,0);

From the logs of pdflatex I can see

===== Image 'tikz2pdf/figure' is up-to-date. ======

which tells that the file checked against being up-to-date is the generated pdf, not the original tikz. Obviously I am missing something.

How do I specify that the file to be checked is the original tikz?

For the background, I use pdflatex and tikz/pgf 2.10.

  • 1
    This is the kind of problem make and makefiles are designed to solve. Is that an option for you? Jul 10, 2013 at 15:56
  • 1
    Yes, it is an option. Though I'd rather let the external library do it itself.
    – user24528
    Jul 11, 2013 at 12:25
  • I would recommend using ctan.org/pkg/memoize or ctan.org/pkg/robust-externalize; both are leagues better than tikzexternalize.
    – mcmuffin6o
    Mar 27 at 18:50

3 Answers 3


In order to recreate files automatically as soon as the picture content has been modified, you will have to install a version of PGF which is more recent than 2.10.

At the time of this writing, this means you would need to (a) wait for the next stable or (b) use the unstable version. You can acquire one by means of CSV. Sometimes one is prepared and made available on http://www.texample.net/tikz/ .

  • So, from your answer to the question that I refer to in my description of the problem, I should have installed the snapshot prepared by Stefan Kottwitz
    – user24528
    Jul 11, 2013 at 12:04
  • My bad, I got confused with the dates and versions. The question that I refer to in the description of the problem dates from May 17th 2012. There you state clearly that the CVS version (at that time) has to be installed. From the sourceforge page I saw that the "last update" is from 2013-05-29, and mistakenly thought it was referring to the latest version of the the code that one can download just in the right (v.2.10). And of course I thought it would contain the updates... When is the next stable release expected for?
    – user24528
    Jul 11, 2013 at 12:18
  • You may need to post this question on the PGF mailing list. Jul 12, 2013 at 17:16

Somebody here (TikZ externalize fails to recognize changes) already posted an alternative solution, based on a self-made routine that compares modification dates and works nicely with pdftex provided that the figures are stored in separate files.

If you're using xetex however, '\pdffilemoddate' is not available. My solution (based on the one linked above) is to add the following to the preamble:

\tikzset{external/system call={%
xelatex \tikzexternalcheckshellescape
-halt-on-error -shell-escape -interaction=batchmode
-jobname "\image" "\texsource"}}
%delete external pdf if old
   \immediate\write18{./deloldext.pl '#1' '#2'}
%include tikz file and call \deloldext

the perl script deloldext.pl is called and compares the modification date of #2 (the pdf) and #1 (the tikz) and delete the pdf it's older:

#!/usr/bin/env perl
use strict;
use File::stat;
my $syntax = "Syntax: $0 <file> <file>\n";
@ARGV == 2 or die $syntax;
chomp(my $file1 = shift);
chomp(my $file2 = shift);
-f $file1 or die "File not found ($file1)!\n";
-f $file2 or die "File not found ($file2)!\n";
if ((stat($file1)->mtime)>(stat($file2)->mtime))

All external source files have to be named *.tikz and if they are stored in subfolders, the same folder-structure has to exist with the ext-figures folder (otherwise it will not be able to store the pdf's there)

Include a tikz in the document, now simply type:

\caption{Indifference Loci in an [\(\theta_i, r\)]-plane for given \(r_i\)}

By adding option to tikzexternalize

\tikzexternalize[up to date check=diff,some other options]

the package will overwrite the default md5 check, therefore bypass the md5 not updating problem. The picture will be updated this way, at least on my machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .