# Beamer: animate package and overlay

I am trying to get an animation running in beamer with the following setup:

\documentclass[]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{blindtext}
\usepackage{calligra}
\usepackage[]{animate}
\mode<presentation>
{
\usetheme{default}
\useoutertheme{default}
\usecolortheme{default}
}
\setbeamersize{text margin left=3pt,text margin right=3pt}
\DeclareGraphicsExtensions{.eps,.jpg,.png}
\graphicspath{ {./Pictures/} }
\begin{document}
\begin{frame}
\begin{columns}
\column{0.5\textwidth}
\centering
\animategraphics[width=0.9\textwidth,keepaspectratio,autopause,autoresume,autoplay,loop]{0.5}{pp_}{1}{54}
\column{0.5\textwidth}
\begin{columns}
\column{0.9\textwidth}
\begin{tikzpicture}[remember picture,overlay]
\node at (2.5,-0.6) [rectangle,draw=white,fill=black,fill opacity=0.7,
rounded corners, text width=0.9\textwidth, text height=0.9\paperheight] (aa) {};
\node at (aa) [rectangle,text width=0.8\textwidth, text=white] () {
\only<1>{\calligra \blindtext}
\only<2>{\calligra \blindtext}
\only<3-4>{\calligra \blindtext}
};
\end{tikzpicture}
\end{columns}
\end{columns}
\end{frame}
\end{document}


The idea is to have an ongoing slide(picture) show in the left column while going through some text in the right column. Since the text is rather big it must be shown consequtive blocks. This is achieved via the "only" command. Now "only" causes beamer to generate, in this example, four slides. The problem is that when one proceeds to the next slide the animation in the left column restarts at frame 0. It occurs that every frame is runnig its own animation. But what I want is a single ongoing animation in the left column invariably of the beamer slide I am currently are.

Any ideas are much appreciated.

• If you mean that there as a wrong bracket in the tikz path ..... I have changed it. – user1407220 Aug 5 '17 at 2:48
• I see. Sorry, I thought it is already from the frame code obvious what I mean and it might be a very common "problem". However, I changed the code but to compile one must set it's own graphic directory. Thanks a lot. – user1407220 Aug 5 '17 at 22:15

Beamer frames with overlays and animate generated animations are problematic. (See ↗Bugs section in the animate documentation.)

As correctly observed by the OP, Beamer produces multiple PDF pages with independent animations in the case of slides with overlays. The current frame number and the playing state, direction and speed would have to be transferred from one animation to the next upon page change, in order to give the illusion of a single animation running.

This can be achieved using the ↗JavaScript interface of animate. The necessary code is executed during Page-Open and Close events of hidden PDF annotations.

Edit: To further enhance overlay awareness of animations, the beamer command \alt<>{}{} can be used to reserve space on "silent" slides (note the draft option in the alternative clause). If this is not desired, the animation can just be put into \only<>{...}:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{kantlipsum}
\usepackage{animate}

\ExplSyntaxOn
\let\myPdfAnnot\pbs_pdfannot:nnnn
\ExplSyntaxOff

\def\putBeforeAnim#1{%
\myPdfAnnot{1ex}{1ex}{0pt}{%
/Subtype/Screen/F 2%
/AA <<%
/PC << % exec on page-close
/S/JavaScript /JS (
try{
var #1CurSpeed  =anim.#1_\thepage.speed;
var #1PlayingFwd=anim.#1_\thepage.isPlaying&&anim.#1_\thepage.playsFwd;
var #1PlayingBwd=anim.#1_\thepage.isPlaying&&(!anim.#1_\thepage.playsFwd);
} catch(e){}
)
>>
>>%
}%
}

\def\putAfterAnim#1{%
\myPdfAnnot{1ex}{1ex}{0pt}{%
/Subtype/Screen/F 2%
/AA <<%
/PO << % exec on page-open
/S/JavaScript /JS (
try{
anim.#1_\thepage.speed=#1CurSpeed;
if(#1PlayingFwd){ anim.#1_\thepage.playFwd(); }
if(#1PlayingBwd){ anim.#1_\thepage.playBwd(); }
} catch(e){}
)
>>
>>
}%
}

\begin{document}
\begin{frame}
\begin{columns}
\column{0.25\textwidth}
Bla, bla\dots

\alt<2->{%
%%%%%%%%%%%%%%%%%%%%%%%
\putBeforeAnim{myAnim}%
%%%%%%%%%%%%%%%%%%%%%%%
\begin{animateinline}[
label=myAnim_\thepage,
width=\linewidth,loop,
controls={play,stop,speed},
buttonsize=1em
]{1}
\multiframe{54}{i=1+1}{\Huge\framebox[1.4em][r]{\i}}
\end{animateinline}%
%%%%%%%%%%%%%%%%%%%%%%%
\putAfterAnim{myAnim}%
%%%%%%%%%%%%%%%%%%%%%%%
}{%
\phantom{\begin{animateinline}[
draft,
width=\linewidth,loop,
controls={play,stop,speed},
buttonsize=1em
]{1}
\multiframe{54}{i=1+1}{\Huge\framebox[1.4em][r]{\i}}
\end{animateinline}}%
}

More bla, bla\dots
\column{0.75\textwidth}\tiny
\begin{enumerate}[<+->]
\item \kant[1]