8

I've read a bunch of questions and answers on these topics as well as the documentation of the external library for tikz. I suspect I fundamentally misunderstand what I'm doing.

I have a mindmap which I'm including in a beamer presentation. It takes forever to compile so I would like to externalise it using the external library. I am also using overlay specifications to gradually make parts of the map visible. The mindmap is prepared in a separate file which I \input with the facilities of standalone.

Without externalisation, my code produces the slides OK. With externalisation, it fails.

This is a Minimal Non-Working Example using beamer, external and standalone. The beamer presentation is in prawf3.tex:

\documentclass{beamer}
\usepackage{standalone}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\makeatletter
    \tikzset{% https://tex.stackexchange.com/a/79572/39222
      beamer externalising/.style={%
        execute at end picture={%
          \tikzifexternalizing{%
            \ifbeamer@anotherslide
            \pgfexternalstorecommand{\string\global\string\beamer@anotherslidetrue}%
            \fi
          }{}%
        }%
      },
      external/optimize=false
    }
\makeatother

\begin{document}

\begin{frame}{A frame}
    \input{prawf3-pic}
\end{frame}

\end{document}

prawf3-pic.tex is as follows:

\documentclass[11pt,tikz]{standalone}

\begin{document}

\begin{frame}{A frame}
    \begin{tikzpicture}[beamer externalising]
        \node (a) {A};
        \only<2->
        \node (b) at (0,1) {B};
    \end{tikzpicture}
\end{frame}

\end{document}

[Obviously, prawf3-pic.tex will not compile on its own as it stands because beamer externalising is not defined in that case. This isn't the problem.]

The code for the beamer externalising style is from Andrew Stacey's answer to a somewhat similar question which lacked the standalone element.

When I try to compile prawf3.tex using pdflatex -shell-escape, the compilation fails with

! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "prawf3-figure0" "\def\tikzexternalrealjob
{prawf3}\input{prawf3}"' did NOT result in a usable output file 'prawf3-figure0
' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled 
system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is a
lso named 'write 18' or something like that. Or maybe the command simply failed
? Error messages can be found in 'prawf3-figure0.log'. If you continue now, I'l
l try to typeset the picture.

but obviously shell escape is enabled as the error itself makes clear.

prawf3-figure0.log includes this just before it gives up with a Fatal error message:

LaTeX Info: Redefining \includegraphics on input line 21.
No file prawf3-figure0.nav.
(./prawf3-pic.tex
\openout5 = `prawf3-figure0.dpth'.

Missing character: There is no ( in font nullfont!
Missing character: There is no b in font nullfont!
Missing character: There is no ) in font nullfont!
Missing character: There is no a in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no ( in font nullfont!
Missing character: There is no 0 in font nullfont!
Missing character: There is no , in font nullfont!
Missing character: There is no 1 in font nullfont!
Missing character: There is no ) in font nullfont!
Missing character: There is no B in font nullfont!
Missing character: There is no ; in font nullfont!
[1

\providecommand \oddpage@label [2]{}
{/usr/local/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
! Extra }, or forgotten \endgroup.
\endframe ->\egroup 
                    \begingroup \def \@currenvir {frame}
l.27 \end{frame}

I tried using {} with \only<2->:

{\node (b) at (0,1) {B};}

but that did not help. (This isn't surprising but it seemed worth trying as it was about the only thing I could think to try.)

Note that I think the complaints about the nullfont are unrelated as I get these with the full example even though everything compiles fine.

EDIT

I'm even more confused now as it turns out that it is not even sufficient to disable externalisation as follows:

\documentclass{beamer}
\usepackage{standalone}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\tikzexternaldisable
\makeatletter
    \tikzset{% https://tex.stackexchange.com/a/79572/39222
      beamer externalising/.style={%
        execute at end picture={%
          \tikzifexternalizing{%
            \ifbeamer@anotherslide
            \pgfexternalstorecommand{\string\global\string\beamer@anotherslidetrue}%
            \fi
          }{}%
        }%
      },
      external/optimize=false
    }
\makeatother

\begin{document}

\begin{frame}{A frame}
    \input{prawf3-pic}
\end{frame}
\end{document}

I thought that disabling externalisation would be sufficient to get compilation since it essentially turns the externalisation off. And beamer externalising seems to be defined conditionally so that it should be innocuous enough in that case...

  • @pluton Do you have this problem? I seem to have figured out how to do this at some point. At least, I certainly externalise TikZ pictures in Beamer now, including ones which use overlay specifications. – cfr Oct 1 '15 at 14:59
  • @pluton That is, I don't have a solution in the form of a style, but I have it working generally. – cfr Oct 1 '15 at 15:07
  • I was interested in externalizing Tikz figures "within beamer" to be able to use beamer fonts within Tikz figures. If you have a solution, I'm interested. Thanks – pluton Oct 1 '15 at 15:10
  • @pluton Sorry. I think all I'm doing is explicitly stating the number of slides to produce per frame. So I'm saying \begin{frame}<1-2>{Title}... rather than \begin{frame}{Title}.... This does work well, but obviously it is not automatic. – cfr Oct 1 '15 at 15:27
1

This version works for me (and is shorter in code).

No need for standalone. That answer should be possible updated, although my score is yet too low to do that.

If you want full automatization, you would need a counter inside.

prawf3.tex

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{external, automata}
\tikzexternalize
\tikzexternaldisable
\makeatletter
\makeatother
\begin{document}
    \begin{frame}{A frame}
        \input{prawf3-pic}
    \end{frame}
\end{document}

prawf3-pic.tex

\only<1-2>{%the count of figures needs to be clear(quick hack)
    \begin{tikzpicture}
        \node (a) {A};
        \only<2->{\node (b) at (0,1) {B};}
    \end{tikzpicture}%
}
0

Workflow for multiple graphics on slides (possibly in background) and on use of \only or similiar tools or/and on unclear rowing of slides for a long presentation (due to possibly long(er) compilation times)

\includegraphics[height=0.65\textheight,keepaspectratio]{tikzGraphics/pdfToInclude}

in combination with

pdflatex -jobname $jn "\\\documentclass{standalone}\\\usepackage{pgfplots,amsmath,ifthen,xcolor}\\\input{../commands.tex}\\\pgfplotsset{compat=1.13}\\\input{../plotadaptions.tex}\\\begin{document}\\\input{$file}\\\end{document}"

did the job for me. As complete shell script

for file in *.tex 
do
    jn=$(basename -s .tex $file)
    pdflatex -jobname $jn "\\\documentclass{standalone}\\\usepackage{pgfplots,amsmath,ifthen,xcolor}\\\input{../commands.tex}\\\pgfplotsset{compat=1.13}\\\input{../plotadaptions.tex}\\\begin{document}\\\input{$file}\\\end{document}"
done

Only some adaptions to set tikz-properties, commands to use and colors are needed and not all PDFs for each slide on changing some graphics need to be compiled. (This can be very unpleasant on having a 80 slides long presentation)

  • 1
    Thanks, but my experience obviously differs from yours. Externalising saves compilation time. Enormously. It makes the unmanageable manageable. I can't imagine why you have to wait for compilation to complete before continuing to edit. I have certainly not had that problem. I don't understand how the prefix suggestion is supposed to help. By the way, you don't need keepaspectratio in your example. The major disadvantage with your suggestion is, of course, that you have to manually ensure consistency of fonts etc. Externalisation avoids that. – cfr Feb 2 '18 at 23:29
  • When you add graphics or slides before the slide to explain stuff, the numbering gets mixed up. Having background images any inserting of <code>\pause,\only,etc</code> changes the numbering on <code>externalization</code> and everything needs to be compiled again. For your use case however that might differ and you are correct, if you do not have background images or multiple images on a slide with \only etc. – Jay-Pi Feb 5 '18 at 22:12
  • No, I often do have multiple images - at least, I often use an image which appears gradually, which amounts to multiple images. And I often use overlay specifications within the tikzpictures for this purpose. I don't generally use changing images as background canvas, though, if that's what you mean. – cfr Feb 5 '18 at 23:55
  • The only tricky bit is getting it to work with handout. But that's just a question of specifying the number of slides. Annoying, but simple enough. – cfr Feb 5 '18 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.