# Externalize pgfpicture [closed]

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 pgfpictures. 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.

-

## closed as too localized by percusse, Claudio Fiandrino, lockstep, Werner, SeamusMar 18 '13 at 16:43

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

A tikzpicture is a special form of a pgfpicture, so you can't use the one inside the other. Note that there is also the standalone 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. – Martin Scharrer Jan 27 '13 at 12:25
\tikzexternalize works only for tikz pictures. Externalization support for pgfpictures is somewhat more low-level than for tikzpictures (which makes perfect sense, since pgf itself is more low-level than tikz). I suggest you read about externalizing pgf graphics in section 80 (Externalizing Graphics, under VII The Basic Layer) of the PGF manual. – Sašo Živanović Jan 27 '13 at 12:57
Thanks. I've read that part of the manual and I've got it working for one graphic. If I have graphics graphic1 and graphic2 and I do pdflatex --jobname graphic1 mydoc.tex, I get "!pdfTeX error: pdflatex (file graphic2): unknown type of image" and vice-versa. – Johannes Bauer Jan 28 '13 at 11:26
I assume you are using matplotlib's PGF backend. You could try matplotlib2tikz instead, which converts to tikz. Depending on what you are doing, you might be interested in my pythontex package, which can also be used to cache matplotlib figures (and can create them in parallel, if your processor has multiple cores). – G. Poore Jan 29 '13 at 1:06
Can I say that this question is exactly what I need too and I feel it shouldn't be closed as too localised? It would be of great benefit to me to find an answer to this! Please reopen – gozzilli Aug 25 '13 at 20:39