Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 692
Kostas Avatar asked Apr 23 '15 11:04

Kostas


2 Answers

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]
like image 192
pchaigno Avatar answered Oct 11 '22 07:10

pchaigno


When you compile generate1.tex file, it will produce generate1.pdf file. When you rename the .tex file (f.e. generate2.tex), new pdf will also have different name (generate2.pdf), thus the old pdf won't be deleted.

If you want to display TikZ images only, use \PreviewEnvironment{tikzpicture}. If you are interested, you can find the sample code here.

If you want to load them, use includepdf.

like image 23
mrek Avatar answered Oct 11 '22 08:10

mrek