[Tex/LaTex] Using the animate package without Adobe

animatebeamerviewers

I'm looking to use the animate package in beamer to display animated graphics to my class, and I was wondering if it'd be possible for the animation to work on their Chromebooks. It seems Adobe isn't supported on ChromeOS, so is there any other alternative?

This question seems relevant, but I don't have any movie files or gifs, just what I've made using the animate package in LaTeX.

I understand this is quite likely not possible, but any help would be much appreciated.

Best Answer

1 beamer class document in SVG format

Think about giving up the PDF format in favour of SVG.

Animations run in all contemporary Web browsers, while Blink-based ones (Chromium, Chrome, Opera) have the best performance. Also run on mobile devices.

Click the image to start presentation in the Web browser and press F11 for full-screen. Navigate through slides with PgUp and PgDown.



Compile the example code with

latex svgbeamer
latex svgbeamer
dvisvgm --font-format=woff2 --bbox=papersize --zoom=-1 -p1,- --output=%f-%1p svgbeamer

Example code svgbeamer.tex:

\documentclass[dvisvgm,hypertex,aspectratio=169]{beamer}
\usefonttheme{serif}

\usepackage{animate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PageDown, PageUp key event handling; navigation symbols
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[totpages]{zref}
\usepackage{atbegshi}
\usepackage{fontawesome}
\setbeamertemplate{navigation symbols}{}
\AtBeginShipout{%
  \AtBeginShipoutAddToBox{%
    \special{dvisvgm:raw
      <defs>
      <script type="text/javascript">
      <![CDATA[
        document.addEventListener('keydown', function(e){
          if(e.key=='PageDown'){
            \ifnum\thepage<\ztotpages
              document.location.replace('\jobname-\the\numexpr\thepage+1\relax.svg');%
            \fi
          }else if(e.key=='PageUp'){
            \ifnum\thepage>1
              document.location.replace('\jobname-\the\numexpr\thepage-1\relax.svg');%
            \fi%
          }
        });
      ]]>
      </script>
      </defs>
    }%
  }%
  \AtBeginShipoutUpperLeftForeground{%
    \raisebox{-\dimexpr\height+0.5ex\relax}[0pt][0pt]{\makebox[\paperwidth][r]{%
      \normalsize\color{structure!40!}%
      \ifnum\thepage>1%
        \href{\jobname-\the\numexpr\thepage-1\relax.svg}{\faArrowLeft}%
      \else%  
        \textcolor{lightgray}{\faArrowLeft}%  
      \fi\hspace{0.5ex}%
      \ifnum\thepage<\ztotpages%
        \href{\jobname-\the\numexpr\thepage+1\relax.svg}{\faArrowRight}%
      \else%
        \textcolor{lightgray}{\faArrowRight}%  
      \fi%
      \hspace{0.5ex}%
    }}%
  }%  
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%required by PSTricks example
\usepackage[dvipsnames,svgnames]{pstricks}
\usepackage{pst-node,pst-plot,pst-eucl}
\usepackage{pst-solides3d}
\usepackage{multido}
\usepackage[nomessages]{fp}

\title{Using package \emph{animate} without Adobe}
\subtitle{Use a Web browser and press \framebox{F11}}
\author{AlexG}
\date{\today}

\begin{document}

\frame{\titlepage}

\begin{frame}{Animation}
  trivial example
  \begin{center}
    \begin{animateinline}[controls]{2}
      \multiframe{10}{i=0+1}{\Huge\fbox{\i}}
    \end{animateinline}  
  \end{center}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  PSTricks example by J. Gilg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\R{4}            % Radius des festen Kreises (Length fixed Circle)  
\def\r{1}            % Radius des abrollenden Kreises (Length rolling Circle)
\def\A{0.75}         % Abstand erzeugenden Punkt zu Mittelpunkt des abrollenden Kreises (Length Pointer)
\def\winkel{360}     % Winkel: 1 Umlauf entspricht 360 (Angle: 1 revolution corresponds to 360)
\FPdiv{\myDeltaA}{\winkel}{90}%

\def\psBall{\rput(0,0){\psSolid[
  object=sphere,r=0.35,
  hue=0 1,
  RotX=\ai\space,ngrid=12](0,0,0)}}

\def\myFigure{%
  \pstVerb{% erzeugender Punkt (parameterized Hypocycloide)
    /Xcoord \ai\space cos \R\space \r\space sub mul \ai\space \R\space \r\space sub \r\space div mul cos \A\space mul add def % (R-r)cos(a)+A cos[(R/r-1) a]
    /Ycoord \ai\space sin \R\space \r\space sub mul \ai\space \R\space \r\space sub \r\space div mul sin \A\space mul sub def % (R-r)sin(a)-A sin[(R/r-1) a]
  }%

  % erzeugender Punkt (generating point)
  \rput(0,0){\rput(!Xcoord Ycoord){\psBall}}%

  \rput(0,0){\psSolid[object=cube,ngrid=4,
     hue=0 1,
     hollow,
     a=0.5,
     RotZ=-\ai\space](0,0,0)%
  }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}[t]{PSTricks Animation}
At the end of a rainbow \dots, by Jürgen Gilg.
\begin{itemize}
  \item best viewed in Blink-based browsers, such as Chromium, Chrome, Opera
  \item frame rate printed to JavaScript console (Ctrl+Shift+I)
\end{itemize}
\begin{center}
  \raisebox{0pt}[0.65\height][0pt]{%
  \pstVerb{/clip {} def}% disable `clip' for much better SVG performance in Firefox
  \begin{animateinline}[measure,loop,controls,height=0.8\textheight]{30}
  \multiframe{90}{i=0+1}{%
    \FPeval{ai}{myDeltaA*\i}%
    \begin{pspicture}(-5,-5)(5,5)\myFigure\end{pspicture}%
  }%
  \end{animateinline}%
}
\end{center}
\end{frame}

\begin{frame}
  \begin{center}\Huge The End\end{center}  
\end{frame}

\end{document}

2 Animated SVG as file attachment to PDF

animate can export to standalone SVG animations, as outlined in https://tex.stackexchange.com/a/136919 . The SVG can be embedded as a file attachment to the PDF, and be run in a Web browser on click or touch:

\usepackage{attachfile} % or attachfile2
...
\textattachfile{animatedImage.svg}{Click!}

or without being attached:

\usepackage{hyperref}
...
\href{run:animatedImage.svg}{Click!}

In either case, the operating system/window manager must be configured to use a Web browser as default application for opening SVG files.

Chromium-based Web browsers (e. g. Chrome, Opera) should be used for viewing animated SVG, because of their extremely good rendering performance. The Lorenz attractor may serve as a test example.

3 As for PDF, ...


... there is very good news! Open-Source PDF viewers are catching up.

Okular from KDE now supports JavaScript-driven animations. See:

https://community.kde.org/GSoC/2019/StatusReports/Jo%C3%A3oNetto

Tested with Okular-1.10 (KDE-20.04.1)


We need an opensource PDF viewer with an opensource JavaScript engine added. All ingredients are there, e.g. Evince, Okular, JavaScriptCore from webkit.org (used by Apples web browser Safari), V8 (Google Chrome) or SpiderMonkey (Firefox).

MuPDF is a good starting point, but its integrated JavaScript support is quite rudimentary.

And the PDF rendering performance should be high, which is crucial for animations. MuPDF is one rendering library. The other two, Okular, Evince are based on the Poppler library.

The faster one, either MuPDF or Poppler should be chosen.

Someone should take up the challenge and put everything together.