3

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}
\usetikzlibrary{arrows,positioning,trees,decorations.pathmorphing,shapes,backgrounds,calc,shadows,decorations.pathreplacing}
\usetikzlibrary{fadings}
 \usetikzlibrary[shadings]
\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.

2
  • If you mean that there as a wrong bracket in the tikz path ..... I have changed it. Aug 5, 2017 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. Aug 5, 2017 at 22:15

1 Answer 1

4

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 #1CurFrame  =anim.#1_\thepage.frameNum;
            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.frameNum=#1CurFrame;
            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]
    \item {\Huge\color{alert} Animation appears!} 
    \item \kant[3]
  \end{enumerate}
\end{columns}
\end{frame}
\end{document}
1
  • Hi there, thanks a lot. I had already a guess in that direction, eg. write the frame number somewhere when autopausing and read it when starting. However, I am almost illiterate when it comes to javascript. So thanks for providing the code. Aug 8, 2017 at 2:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .