Is there a way using e.g. the external
TikZ library to produce, from a master LaTeX document, another LaTeX source where each tikzpicture
environment is replaced by the appropriate includegraphics
command?
This can be painful to do by hand in a document which contains many such environments.
Example master document x.tex
:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{...}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
...
\begin{figure}
\begin{tikzpicture}
...
\end{tikzpicture}
\caption{A}
\end{figure}
\begin{figure}
\begin{tikzpicture}
...
\end{tikzpicture}
\caption{B}
\end{figure}
...
\end{document}
desired output:
\documentclass{article}
\usepackage{graphics}
\begin{document}
...
\begin{figure}
\includegraphics{x-figure0}
\caption{A}
\end{figure}
\begin{figure}
\includegraphics{x-figure1}
\caption{B}
\end{figure}
...
\end{document}
Best Answer
All about
externalization
is explained is section "50 Externalization Library" and how to send a tex file withtikzpictures
without usingtikz
is explained in section "50.5 Using External Graphics Without pgf Installed". So, please read these pages. What follows is just a short recipe without to many details. The code has been borrowed frompgfmanual
.The original file contains
tikzpictures
which are externalizated. It loadtikz
andexternal
library. With command\tikzexternalize
, alltikzpictures
are extracted and processed. For amain.tex
file severalmain-figureX.pdf
(and some.dpth
).Once all figures are correct. Preamble is changed to:
tikz
package andexternal
library are not used any more and are replaced bygraphicx
andtikzexternal
packages (tikzexternal.sty
is in folderlatex/pgf/utilities/tikzexternal.sty
and you must copy it to your working folder).Next run will load
.pdf
figures instead of generating them.