When I do
\tikzexternalize
\tikzsetfigurename{foo}
\begin{tikzpicture}
...
\end{tikzpicture}
and compile my LaTeX file with pdflatex --shell-escape
, a file foo0.pdf
is created the first time and that PDFfile is just included from then on.
However, the same doesn't work for pgfpicture
s. I'm creating figures using matplotlib
(which rocks, btw.) and they're plain PGF. When I include those, they are compiled every time, which is pretty time consuming.
I didn't find any way to include a pgfpicture
in a tikzpicture
. When I tried simply to do something like this:
\begin{tikzpicture}
\begin{pgfpicture}
...
\end{pgfpicture}
\end{tikzpicture}
I got "TeX capacity exceeded" errors.
tikzpicture
is a special form of apgfpicture
, so you can't use the one inside the other. Note that there is also thestandalone
bundle which allows to compile picture environments or any other LaTeX material just once and automatically include the resulting PDF then. However, it works the other way around: the pictures are supposed to be inside a file of its own with an own preamble.\tikzexternalize
works only fortikz
pictures. Externalization support forpgfpictures
is somewhat more low-level than fortikzpictures
(which makes perfect sense, sincepgf
itself is more low-level thantikz
). I suggest you read about externalizingpgf
graphics in section 80 (Externalizing Graphics, under VII The Basic Layer) of the PGF manual.graphic1
andgraphic2
and I dopdflatex --jobname graphic1 mydoc.tex
, I get "!pdfTeX error: pdflatex (file graphic2): unknown type of image" and vice-versa.matplotlib
's PGF backend. You could try matplotlib2tikz instead, which converts to tikz. Depending on what you are doing, you might be interested in mypythontex
package, which can also be used to cache matplotlib figures (and can create them in parallel, if your processor has multiple cores).