7

I've built a beamer presentation in which a TikZ graph is built up sequentially using \pause. Example:

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
        \begin{frame}
                \begin{tikzpicture}[ scale=5 ]
                        \draw (0,0) -- (1,0) node[below] {$f_1$};
                        \pause
                        \draw (0,0) -- (0,1) node[left] {$f_2$};
                        \pause
                        \draw (0,0) -- (0.87,0.5) node[right] {$f_3$};
                \end{tikzpicture}
        \end{frame}
\end{document}

This results in three slides. I want these as three separate images in which each TikZ picture covers an entire "page" or "slide". That is, I want the output slide1.pdf, slide2.pdf and slide3.pdf, and in each of them, the TikZ picture should cover the entire slide.

I could accomplish this by creating three standalone .tex files with a lot of duplicate TikZ code, but I suppose there is a better way.

What is a good solution?

Tim N
  • 10,219
  • 13
  • 63
  • 88
  • You could extract them from the beamer presentation using the pdfpages package. You could also use the plain option for the frame environment so that you won't have headers/footers etc. – mbork Mar 31 '14 at 12:40
  • This is a tip with \only in use: http://tex.stackexchange.com/questions/119428/beamer-overlays-tikz-external-and-custom-file-name – Malipivo Mar 31 '14 at 13:02

2 Answers2

18

I'm not sure about the question but I think you're looking for standalone

\documentclass[beamer]{standalone}
\usepackage{tikz}
\begin{document}
        \begin{standaloneframe}
                \begin{tikzpicture}[ scale=5 ]
                        \draw (0,0) -- (1,0) node[below] {$f_1$};
                        \pause
                        \draw (0,0) -- (0,1) node[left] {$f_2$};
                        \pause
                        \draw (0,0) -- (0.87,0.5) node[right] {$f_3$};
                \end{tikzpicture}
        \end{standaloneframe}
\end{document}

produces a three pages/frames pdf document.

enter image description here

You can include them as background in any beamer presentation with \includegraphics[page=x]{your-standalone-file.pdf} where x=1,2,3.

With standaloneframe you don't have to worry about different figure sizes because all of them are equal.

\documentclass{beamer}

\begin{document}
\setbeamertemplate{background}{\includegraphics[page=1]{168685}}
        \begin{frame}{First frame}
        \end{frame}
\setbeamertemplate{background}{\includegraphics[page=2]{168685}}
        \begin{frame}{Second frame}
        \end{frame}
\setbeamertemplate{background}{\includegraphics[page=3]{168685}}
        \begin{frame}{Third frame}
        \end{frame}
\end{document}

enter image description here

Ignasi
  • 136,588
1

If you use \documentclass[tikz]{standalone}, then each tikzpicture environment in the document will create a different page.

Then, you can include each page separately in your document. I use a \foreach loop to generate multiple tikzpicture environments and set various toggles and values based on the slide number.

Here's an example of the standalone document.

% Using the 'tikz' option causes each tikz diagram to be displayed on a different page.
\documentclass[tikz]{standalone}
\usepackage{etoolbox}% Provides \newtoggle

\newtoggle{showLines} \newtoggle{showRegions}

\begin{document} \foreach \slideNumber in { 0, % Slide that is never shown. Used to adjust the timing of overlays in Beamer slideshow. 0, % Circle only 10, % Lines 20, % Regions (blue) 30 % Regions (red) }{%

\ifnum \slideNumber > 9 \toggletrue{showLines} \fi

\ifnum \slideNumber > 19 \toggletrue{showRegions} \fi

\ifnum \slideNumber > 29 \def\fillColor{blue} \else \def\fillColor{red} \fi

\tikzset{regions/.style={fill=\fillColor}}

\begin{tikzpicture}[scale=1.2]

  \iftoggle{showRegions}{
      % Draw shaded regions
      \fill[regions] (0, 1) -- (1, 1) -- (1, 0) -- cycle;
      \fill[regions] (0, 1) -- (-1, 1) -- (-1, 0) -- cycle;
      \fill[regions] (0, -1) -- (1, -1) -- (1, 0) -- cycle;
      \fill[regions] (0, -1) -- (-1, -1) -- (-1, 0) -- cycle;
  }{}% END 'showRegions'

  \iftoggle{showLines}{%
      \draw (0.0, 0.0) -- (1, 1);
      \draw (0.0, 0.0) -- (-1, 1);
      \draw (0.0, 0.0) -- (1, -1);
      \draw (0.0, 0.0) -- (-1, -1);
  }{}% End 'showLines'

  \draw (0,0) circle[radius=1cm];

\end{tikzpicture} }

\end{document}

Output enter image description here Note that this PDF has five pages (arranged horizontally).

Here is an example Beamer slideshow that uses the resulting TikZ images:

\documentclass{beamer}

% Access the current Beamer overlay value, % per https://tex.stackexchange.com/a/55066/153678 \makeatletter \newcommand*{\overlaynumber}{\number\beamer@slideinframe} \makeatother

\begin{document}

\begin{frame}

\begin{columns} \begin{column}[T]{0.48\textwidth} Here is my first thing to say. There is nothing to see here yet. \pause \begin{itemize}[<+->] \item Now there is a circle. \item Crossed by lines. \item Add some red corners. \item Make them blue. \end{itemize} \end{column} \hfill \begin{column}[T]{0.48\textwidth} % Start showing the images on the second slide. % Set the page of the PDF displayed equal to \includegraphics<2->[page=\overlaynumber]{path/to/tikzoutput.pdf} \end{column} \end{columns}

\end{frame}

\end{document}

Output enter image description here

Paul Wintz
  • 402
  • 2
  • 14