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}
?width=\linewidth
. Which is yourdvisvgm
version? (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
\animategraphics[controls,loop,autoplay,width=\linewidth]{16}{tmp/raycasting_frame}{}{}
.example.svg
that 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: tug.org/texlive/pretest.htmldvisvgm
in TeXLive-2020 will solve my issue? Regarding thewidth=\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!)