export Tikz figures to PDF
You can do this with the TikZ library external
. It saves each picture in an external file, which has a proper graphics format. From now on TikZ will read the external file unless you tell it to regenerate the external file.
There are several methods that regenerate the external graphics files. For example, by setting the TikZ key external/force remake
at the start of your document, you tell TikZ to regenerate subsequent external pictures. You may set the key as follows: tikzset{external/force remake}
. Other methods, including methods that use Makefiles, are explained in Section 32.4.3 of the pgf
manual.
The following is shamelessly copied from the TikZ manual.
Note: You have to run LaTeX with shell-escape
enabled.
\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}
If you are on Windows or Linux you can use QtikZ, a dedicated TikZ editor that offers live compilation of your TikZ code and export to PDF and other formats.
You can also consider the standalone package to generate PDF compiling your TikZ code alone with pdflatex
.
Finally, TikZ offers the external
library to generate PDFs during the first compilation of your main file (chapter 32 of the manual).