1

I have a picture with overlays in an external file. Sometimes I want to use all overlays from the picture, sometimes only some of the overlays.

Consider the following example, where the picture is defined using tikz and included via standalone. In the first frame I want to use all overlays from the picture. However, in the second I frame I only want to use the last two overlays, without changing the picture.

Currently the only way I know to do this is to adapt the overlays of the whole frame to meet the requirements for the overlays I want to include, as shown below. However, it would be nicer not to adapt the whole frame for this.

I found something related here and tried to use it, by setting \beamer@slideinframe to 2 before including the picture. Then however, only the second overlay is shown, but not the third. Something like \only-use-overlays<2,3>{...} would be nice.

If possible it would be nice to select arbitrary frames, but currently I don't need that.

\documentclass{beamer}
\usepackage{standalone, filecontents, tikz}
\begin{document}
\begin{filecontents}{pic.tex}
    \documentclass[beamer]{standalone}
    \begin{document}
    \begin{standaloneframe}
    \begin{tikzpicture}
    \node<1-> [draw] (n0) {$n_0$ }; 
    \node<2-> [draw] (n1) [right of=n0] {$n_1$ }; 
    \node<3-> [draw] (n2) [right of=n1] {$n_2$ }; 
    \end{tikzpicture}
    \end{standaloneframe}
    \end{document}
\end{filecontents}
% This frame has 3 overlays.
\begin{frame}
    First Slide
    \includestandalone{pic}
\end{frame}
% This frame has two overlays. 
% The first overlay contains the first item and the second overlay of the picture.
% The second overlay contains the second item and the third overlay of the picture.
\begin{frame}<2,3>
    Second Slide
    \begin{itemize}
        \item<+(1)> First item
        \item<+(1)> Second item
    \end{itemize}
    \includestandalone{pic}
\end{frame}
\end{document}
  • 1
    Both images separately on the same slide at the same time? \only<2-3>{\begin{standalone}...\end{standalone}} is probably not what you want – user31729 Apr 13 '15 at 20:14
  • Thanks for your comment. It seems the pictures were misleading, so I reformulated the question. – Heinrich Ody Apr 13 '15 at 21:19
1
\documentclass{beamer}
\usepackage{standalone, filecontents, tikz}
\begin{document}
\begin{filecontents}{pic.tex}
    \begin{tikzpicture}
    \draw[use as bounding box] (0,0) rectangle (3,3);
    \draw<1-> (0,0) -- (3,3);
    \draw<2-> (3,0) -- (0,3);
    \draw<3-> (0,1) -- (3,1);
    \end{tikzpicture}
\end{filecontents}
\begin{frame}
    First Slide
    \includestandalone{pic}
\end{frame}
\begin{frame}
    Second Slide
    \begin{itemize}
        \item<+-> First item
        \item<+-> Second item
    \end{itemize}
    % Here I only want the last two overlays ff the picture
    \onslide<2,3>{
      \includestandalone{pic}
    }
\end{frame}
\end{document}
  • 1
    From your question it is not completely clear to me, how you want the local overlay specifications to interact with the included ones. Should the "last two overlays" from the picture [a] appear in steps 2 and 3 on "Second Slide" (as above), or [b] as steps 3 and 4 (i.e., after the items), or [c] as steps 1 and 2 (i.e., together with the items)? – Daniel Apr 13 '15 at 21:58
  • Thanks @Daniel, I edited the question to remove the doubt. The MWE now shows the desired result, but uses ugly methods. – Heinrich Ody Apr 14 '15 at 6:59
  • @HeinrichOdy: I think this "ugly methods" are your way to go. – Daniel Apr 14 '15 at 9:55
1

As mentioned in the question there was a related question. I can just use the method given there in a loop.

The example below produces the same output as the example in the question, however it is not necessary to adapt the whole frame to the overlays to be included. The optional parameter to \includestandaloneslides specifies from which slide on all overlays from #2 (which is a tikz list) should be used.

Still the construction seems quite crude.

\documentclass{beamer}
\usepackage{standalone, filecontents, tikz}
\makeatletter
\newenvironment{inframe}[2][1]{%
  \edef\inframe@current{\the\value{beamerpauses}}%
  \setcounter{beamerpauses}{#1}%
  \beamer@slideinframe=#2\relax
  \let\beamer@anotherslidetrue=\@empty
  \let\beamer@localanotherslidetrue=\@empty
}{%
  \setcounter{beamerpauses}{\inframe@current}%
}

\newcommand*{\includestandaloneslides}[3][0]{
    \foreach [count=\i] \slide in #2{
        \pgfmathtruncatemacro{\n}{\i + #1}
        \only<\n>{
            \begin{inframe}{\slide}
            \includestandalone{#3}
            \end{inframe}
        }   
    }
}
\begin{document}
\begin{filecontents}{pic.tex}
    \documentclass[beamer]{standalone}
    \begin{document}
    \begin{standaloneframe}
    \begin{tikzpicture}
    \node<1-> [draw] (n0) {$n_0$ }; 
    \node<2-> [draw] (n1) [right of=n0] {$n_1$ }; 
    \node<3-> [draw] (n2) [right of=n1] {$n_2$ }; 
    \end{tikzpicture}
    \end{standaloneframe}
    \end{document}
\end{filecontents}
% This frame has 3 overlays.
\begin{frame}
    First Slide
    \includestandalone{pic}
\end{frame}
% This frame has two overlays. 
% The first overlay contains the first item and the second overlay of the picture.
% The second overlay contains the second item and the third overlay of the picture.
\begin{frame}
    Second Slide
    \begin{itemize}
        \item<+> First item
        \item<+> Second item
    \end{itemize}
    \includestandaloneslides{{2,3}}{pic}
\end{frame}
\end{document}

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.