7

I am currently working on a conference presentation and I am using the very nice tikz and pgfplotspackages in combination with beamer.

To stress out some content in my figures, I use beamer's overlay system.

When I use some small tikzpictures everything is integrated inside the document using some \input commands. However, for large pgfplots figures (you see me coming), I have quite long compilation times.

My current solution is to precompile my big pictures separately using multiple tikzpictures and to call some \includegraphics with overlay options.

Beamer code

\documentclass{beamer}
\begin{document}
\begin{frame}
\includegraphics<1>[page=1]{image}
\includegraphics<2>[page=2]{image}
\includegraphics<3->[page=3]{image}
\end{frame}
\end{document}

where image is built using

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[]
    % Plot to be displayed on overlay 1
        \addplot[domain=0:1,samples=100]{x}; 
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[]
        % Plots to be displayed on overlay 2
        \addplot[domain=0:1,samples=100]{x}; 
        \addplot[domain=0:1,samples=100]{x^2}; 
    \end{axis}
\end{tikzpicture}
% And so on
\end{document}

I know there are some externalization ways to do this, but I was wondering what the opinion of the community was on this matter.

Sorry in advance, if this is a double.

EDIT related to standalone beamer option

Using standalone with the beamer option seems to produce an nteresting result (thanks samcarter). However, the output has the size of a beamer frame, instead of fitting the pgfplots axis. See the MWE below.

\documentclass[beamer]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{standaloneframe}
\begin{tikzpicture}
\begin{axis}[]
\only<1>{\addplot[domain=0:1, samples=100]{x};}
\addplot[domain=0:1, samples=100]{x^2};
\addplot[domain=0:1, samples=100]{x^3};
\only<4>{\addplot[domain=0:1, samples=100]{x^4}};
\end{axis}
\end{tikzpicture}
\end{standaloneframe}
\end{document}
BambOo
  • 8,801
  • 2
  • 20
  • 47

1 Answers1

5

Pass the tikz and preview options to standalone:

\documentclass[beamer,tikz,preview]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{standaloneframe}
\begin{tikzpicture}
  \begin{axis}[]
  \only<1>{\addplot[domain=0:1, samples=100]{x};}
  \addplot[domain=0:1, samples=100]{x^2};
  \addplot[domain=0:1, samples=100]{x^3};
  \only<4>{\addplot[domain=0:1, samples=100]{x^4}};
  \end{axis}
\end{tikzpicture}
\end{standaloneframe}
\end{document}

Compiling this with pdflatex results in a nicely cropped, 4 page PDF. For easy embedding into the beamer frames, I recommend the following pattern:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
  \foreach \ov/\pg in {1/1,2/2,3-/3}{ 
    \includegraphics<\ov>[page=\pg]{image.pdf}
  } 
  \onslide<4>{Still the last figure!}
\end{frame}
\end{document}
Daniel
  • 37,517