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

11,842

Solution 1

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]

Solution 2

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.

Share:
11,842

Related videos on Youtube

Kostas
Author by

Kostas

Updated on September 16, 2022

Comments

  • Kostas
    Kostas over 1 year

    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?

  • drumath
    drumath almost 2 years
    Note that you may need to add the -shell-escape flag when compiling. E.g. pdflatex -shell-escape main.tex.