2

Within my larger pdf document I have what is basically a slideshow that steps through a set of frames created using the animateinline environment. I would like to add a frame counter of the form "Frame 12 of 32".

I can imagine two possible approaches:

  • When the frames are created by the animate package, if there was a LaTeX counter available that corresponded to the frame number then it could be simply displayed as part of that frame.
  • Or, when the frames are being played back, have some javascript which updates a frame counter displayed somewhere on the page. I know from the animate documentation that I can get or set the frame number but don't know how to display and update this info.
2

The following example uses animate-internal counters and a macro to write information (frame count) into the aux file. This corresponds to the first of your suggested approaches. The counter is inserted using the \framecounter command.

\documentclass{article}
\usepackage{animate}

%%%%%%%%%%%%%%%%%%%%%%%% \framecounter %%%%%%%%%%%%%%%%%%%%%%%%%
% Within `animateinline', inserts `curr. #frame / total #frame'.
\makeatletter
\newcommand\framecounter{%
  \edef\the@frame{\the\numexpr\@anim@curframe@zb+1\relax}%
  \@anim@keytoaux{a\the\@anim@num.last}{\the@frame}%
  \framebox[\widthof{%
    -\@anim@getkeyval{a\the\@anim@num.last}/%
    \@anim@getkeyval{a\the\@anim@num.last}-%
  }]{\strut\the@frame/\@anim@getkeyval{a\the\@anim@num.last}}%
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\mybox[1]{\framebox[\widthof{-jumps-}]{\strut#1}}

\begin{document}

\begin{animateinline}[
  step,
  end=\framecounter %insert at the end of every frame
]{1}
  \mybox{The}
\newframe
  \mybox{quick}
\newframe
  \mybox{brown}
\newframe
  \mybox{fox}
\newframe
  \mybox{jumps}
\newframe
  \mybox{over}
\newframe
  \mybox{the}
\newframe
  \mybox{lazy}
\newframe
  \mybox{dog.}
\end{animateinline}

\end{document}
  • Excellent. Just what I needed. Sorry I can't vote up your answer but this is my first foray into tex.stackexchange and I don't have enough points to do so. – Paul Rippon Mar 18 '15 at 21:51

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.