1

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.
0

1 Answer 1

1

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\@[email protected]}{\the@frame}%
  \framebox[\widthof{%
    -\@anim@getkeyval{a\the\@[email protected]}/%
    \@anim@getkeyval{a\the\@[email protected]}-%
  }]{\strut\the@frame/\@anim@getkeyval{a\the\@[email protected]}}%
}
\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}
1
  • 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. Commented Mar 18, 2015 at 21:51

You must log in to answer this question.

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