How to export every TikZ image to a separate pdf file?

Kostas picture Kostas · Apr 23, 2015 · Viewed 9.8k times · Source

I'm creating some graphs for my thesis in a single .tex file using the TikZ package in LaTeX.
I'm using the standalone document class so that my graphs are generated without whitespaces.

How can I export every graph in a separate PDF file so I can load them individually in another project?

Answer

pchaigno picture pchaigno · Aug 9, 2017

The tikz library external does just what you want:

\usetikzlibrary{external}
\tikzexternalize

It will generate one PDF per tikzpicture. You can define an output directory with:

\tikzexternalize[prefix=./dir]