7

I saw Why is tikz so much slower when plotting a huge amount of data than WYSIWYG plotting tools? that pgfplots can be configured to do the plotting only once. How to do this? I have a document with many graphs and repeated runs takes so much time.

4
  • 1
    See Section 32 Externalization Library of the tikz/pgf manual. Basically \usetikzlibrary{external} \tikzexternalize should be all you need. Commented Apr 3, 2012 at 23:56
  • Thanks for the reply. It does work. But I have a small problem. Every time I run pdflatex, it stops in between saying that the system call 'pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "pami2012-figure2" "\def\tikzexternalrealjob{pami2012}\input{pami2012}"' did NOT result in a usable output file 'pami2012-figure2' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. Actually I have enabled write18 and the pdf of each of the figures are produced also. I manage by pressing 's', but how to avoid that?
    – suresh
    Commented Apr 4, 2012 at 0:20
  • 1
    It would be helpful if you would compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages. This will also serve as a test case and ensure that the solution actually works for you. In the mean time, perhaps try adding -enable-write18 and ensure that you do not have older .aux files lying around. Commented Apr 4, 2012 at 0:24
  • It is fine now. There was another error (file missing) which caused this behavior I guess. But that error did not show up instead the previous one (the one I posted earlier) showed up. Thanks again. It is difficult to imagine when one quickly thumbs through the pgf manual that it is the externalization library that is needed.
    – suresh
    Commented Apr 4, 2012 at 0:28

1 Answer 1

5

The details of this are described in Section 32 Externalization Library of the tikz/pgf manual.

Basically adding the following to your preamble should be all that is needed:

\usetikzlibrary{external} 
\tikzexternalize
9
  • How the tex/pgfplots will identify if I modify the plots environment? Should I manually delete the pdf file created in the earlier runs?
    – suresh
    Commented Apr 4, 2012 at 0:34
  • That is one reason why it is better to keep the figures in external files and include them in your main document. Deleting the externally generated figures will should work. You could also try \tikzset{external/force remake}, which is not something I have used. Commented Apr 4, 2012 at 0:44
  • I deleted the pdf files tex created and it did work. What do you mean by "keep the figures in external files"? Another latex file with tikzpicture environment and include that? But then how will that help this situation?
    – suresh
    Commented Apr 4, 2012 at 0:53
  • 2
    There are many references to the standalone pacakge on this site. For instance see How can I generate just pgf/TikZ images, not placed a whole page or slide? Commented Apr 4, 2012 at 1:14
  • 1
    You can use \tikzset{external/force remake} to remake all following tikzpictures, or \tikzset{external/remake next} to only remake the next tikzpicture.
    – Jake
    Commented Apr 4, 2012 at 6:53

You must log in to answer this question.

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