I recently discovered the animate package (actually it was here, looking for alternatives I came across this: https://tex.stackexchange.com/a/235180/212085) and I want to generate two different versions of my beamer slides for a course:
- PDF (with no animation at all if you use free software viewers as I do)
- SVG (with animations, viewing the slides in a browser)
My problems start when I try to get running the most simple example with \animategraphics in a beamer slide. I am able to get a standalone document working ok, the issue arises when using the beamer document class. I tried several examples I found with \animateinline and they work flawlessly (for example, the svgbeamer.tex file that AlexG provides in https://tex.stackexchange.com/a/235180/212085)... but I can not get it to work with a very simple \animategraphics prototype.
For my first example I'm using this public domain annimated gif (https://upload.wikimedia.org/wikipedia/commons/e/e7/Simple_raycasting_with_fisheye_correction.gif) and after slice it in the corresponding 40 frames with ImageMagick's convert (I generated PNG and EPS files to try both LaTeX and XeLaTeX).
Using the minimal template provided by the author in the official doc, I wrote this simple beamer example (example.tex):
\documentclass[dvisvgm,aspectratio=169]{beamer}
\usepackage{animate}
%\usepackage{graphicx} % already included by beamer
%\usepackage{tikz} % already included by beamer
\begin{document}
\begin{frame}{Simple raycasting animation}
\animategraphics[controls,loop,autoplay]{16}{tmp/raycasting_frame}{00}{39}
\end{frame}
\end{document}
then
latex example
latex example
... and the DVI file looks Ok (static, but Ok). Then:
dvisvgm --font-format=woff --zoom=-1 -p1,- example
creates the SVG file and provides this feedback:
pre-processing DVI file (format version 2)
processing page 1
graphic size: 455.24408pt x 256.074799pt (159.999995mm x 89.999998mm)
output written to example.svg
1 of 1 page converted in 2.84687 seconds
However, the animation seems to be "out" of the viewport in the SVG. Only the title of the slide and the controls are visible when rendering the file in the browser, and opening it with Inkscape shows the picture below the slide. Here you can get both files (DVI and SVG) to know what I mean:
Curiously (or not), if I remove the dvisvgm parameter from the document class the final SVG has the picture in the viewport and perform the whole animation just once (and quite fast), but controls do not work. In this case, the picture does not appear in the previous DVI file :-?
UPDATE:
After the kind answers I have just checked the multi-page PDF approach (I'd rather this alternative than using PNG or EPS images) and I do not detect any change when opening the SVG from browser but I can not see now the picture at all when opening it with Inkscape (so I assume it was not been embedded in the SVG, as the file size corroborates).
These are the new files I have generated using the multi-pdf method:
The process now was:
xelatex -no-pdf example2
xelatex -no-pdf example2
dvisvgm --font-format=woff --zoom=-1 -p1,- example2.xdv
dvisvgm provided this output:
pre-processing DVI file (format version 7)
processing page 1
graphic size: 455.24408pt x 256.074799pt (159.999995mm x 89.999998mm)
output written to example2.svg
1 of 1 page converted in 0.283845 seconds
The only change in example.tex (now example2.tex) was the \animategraphics invocation:
\animategraphics[controls,loop,autoplay,width=\linewidth]{16}{tmp/raycasting_frame}{}{}
I have also added the output from dvisvgm in the previous text (when using latex and EPS files instead of xelatex and A multi-page PDF).
By the way, I am using TeXLive-2019 (so dvisvgm 2.9) in a Debian system.
UPDATE2:
I have updated TeXLive from 2019 to 2020 (I have used Debian experimental packages) and I downloaded and compiled dvisvgm 2.9.1 (from https://dvisvgm.de)... and that did the trick! (at least for the EPS files approach)
Now the example.svg file generated from example.tex doing latex example; latex example; dvisvgm --font-format=woff --zoom=-1 -p1,- example runs the animation perfectly.
I am still stuck with the multi-page PDF alternative, though. Following @AlexG advice I have added \usepackage{pdfbase} to the preamble of example3.tex (that is the only difference with example2.tex) and after xelatex -no-pdf example3; xelatex -no-pdf example3; dvisvgm --font-format=woff --zoom=-1 -p1,- example3.xdv I get these files (I am also attaching the log file):
\begin{frame}[fragile]{Simple raycasting animation}? – Toño Apr 08 '20 at 13:04width=\linewidth. Which is yourdvisvgmversion? (dvisvgm --version). Also note that PNG is not inlined into the SVG code, the image files remain separate from the SVG. So it is better to convert the GIF to multipage PDF:convert -coalesce Simple_raycasting_with_fisheye_correction.gif raycasting_frame.pdf– AlexG Apr 08 '20 at 13:26\animategraphics[controls,loop,autoplay,width=\linewidth]{16}{tmp/raycasting_frame}{}{}. – AlexG Apr 08 '20 at 13:32example.svgthat you didn't use the most recentdvisvgm-2.9.1. You are probably still using TeXLive-2019. You will have to wait two days for TeXLive-2020 (to be released on 10th April). Or, if you cannot wait, install the pre-test version: https://www.tug.org/texlive/pretest.html – AlexG Apr 08 '20 at 14:16@AlexG Thank you very much for pointing me out the multi-pdf approach. I'd rather this method for my use case (slides in both PDF and SVG). Anyway, I am still not obtaining the animation in the slide... :-?.
So... do you think the new
dvisvgmin TeXLive-2020 will solve my issue?Regarding the
width=\linewidth, I was actually using it before writing the example to paste here.Thank you very much for your help! (and for your great LaTeX package!)
– Emilio J. Padrón Apr 09 '20 at 07:44pdfbase.sty, as of 2020/03/25, which is part of pkgmedia9, version 1.10. There was an issue with this package that lead to the symptoms you describe. However, the fixed version needs dvisvgm-2.9.1, which is only in TeXLive-2020 and in the current MiKTeX. – AlexG Apr 09 '20 at 09:29I would like to be able to get the multi-PDF alternative working as well. I have tried adding
– Emilio J. Padrón Apr 09 '20 at 12:21\usepackage{pdfbase}but apparently it did not change anything. I am using TeXLive 2020.20200329 (Debian experimental packages) andmedia9.stysays version is 1.10.type=pdfto ensure\animategraphicsindeed usestmp/raycasting_frame.pdf. – AlexG Apr 09 '20 at 12:28\usepackage{pdfbase}(and also the log file from XeLaTeX). I am now using the parametertype=pdfbut I have not noticed any difference, so I assume it is actually using the PDF file. Thanks! – Emilio J. Padrón Apr 09 '20 at 16:41xcolor, also loaded bybeamer, loads the wrong driver file. I am about writing an answer with solution. Just a minute. – AlexG Apr 09 '20 at 20:08