I have a complex animation that evolves over a series of slides (a \foreach \frm in {1,...,12}\only<\frm>{ loop where certain parts are selected on individual slides with \visible).
So far I had all overlays inside a single frame, but I would like to distribute it to several frames so I can put other frames (with text and other things) in between, so I moved the entire tikzpicture where all overlays are created into a \newcommand{\makeAnimation}[1] such that I can say, e.g.
\begin{frame}{First part of the animation}
\makeAnimation{1,...,4}
\end{frame}
\begin{frame}{Some explanations}
Lorem ipsum
\end{frame}
\begin{frame}{Next part}
\makeAnimation{4,...,7}
\end{frame}
(It is easier to create the whole thing in one go, because I would have to copy a lot of code otherwise)
However, the after the portion of the animation that is (correctly) generated by \makeAnimation{1,...,4} I get an extra empty slide, which I am unable to move away. Worse, if I change the \only after the \foreach statement, into a \visible (this keeps the centered tikzpicture from jumping around) it generates all slides from 1 ... 12 but leaves 5 ... 12 blank.
How can I fix this and get rid of the extra slides? At this point I would accept any hack as long as I don't have to split up/redo the animation.
Small example:
\documentclass[
presentation,
english,
]{beamer}
%\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{tikz}
\newcommand{\makeAnimation}[1]{
\begin{center}
\scalebox{0.7} {
\begin{tikzpicture}
\foreach \frm in {#1} {
\only<\frm>{
\node {FRAME \frm};
\visible<3>{\node at (4,0) {three hippos};}
\visible<4-5>{\node (a) at (2,0) {a couple giraffes};}
\visible<5-6>{\node (b) at (4,2) {hello};}
\visible<5>{\path[-] (a) edge (b);}
\visible<6>{\node at (4,0) {six elephants};}
}
}
\end{tikzpicture}
}
\end{center}
}
\begin{document}
\begin{frame}{foo}
\makeAnimation{1,...,4}
\end{frame}
\begin{frame}{bar}
next slide
\end{frame}
\end{document}
Produces
foo FRAME 1
foo FRAME 2
foo FRAME 3 three hippos
foo FRAME 4 a couple giraffes
foo % evil blank slide
bar next slide

\makeanimationfor instance. Best would be to just add a complete minimal working example showing the problem. – Roelof Spijker Mar 1 '12 at 10:52onlytovisiblewill produce two blank slides. – bitmask Mar 1 '12 at 11:10