7

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.

7
  • 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. Jan 27, 2013 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. Jan 27, 2013 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. Jan 28, 2013 at 11:26
  • 1
    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, 2013 at 1:06
  • 2
    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, 2013 at 20:39

0

Browse other questions tagged or ask your own question.