TransWikia.com

animategraphics is off center in beamer (using animate package)

TeX - LaTeX Asked on July 16, 2021

I’m trying to use the animate package, but when I insert an animation into beamer using the animategraphics command, the result is horribly off-center. This occurs even if I use begin{center}end{center} commands.

Here’s some stripped-down code to illustrate the problem. I used colors so that the off-centeredness is clearly visible.

Here’s the “master” file:

documentclass{beamer}[16:9]
usepackage{animate}
begin{document}
{setbeamercolor{background canvas}{bg=blue}
begin{frame}
animategraphics[]{1}{animate-test-frames}{0}{0}
end{frame}
} % end setbeamercolor
end{document}

And here’s the animate-test-frames.tex file to go with it:

documentclass{beamer}[16:9]
begin{document}
{setbeamercolor{background canvas}{bg=red}
begin{frame}
end{frame}
} % end setbeamercolor
end{document}

This produces the following output:

enter image description here

It seems like there should be a simple way to fix this. Any ideas?

Thanks!

One Answer

A similar result would be obtained with includegraphics[page=1]{animate-test-frames}. The PDF with animation frames is too wide to be inserted as normal slide content.

Use a combination of usebackgroundtemplate{...} and an empty plain frame{} that is put in a group ({...}) in order to insert a slide-filling animation. The plain option should be set in case the presentation makes use of a theme, as in this example:

documentclass[aspectratio=169]{beamer}

usetheme{Warsaw}
usepackage{graphicx}
usepackage{animate}

begin{document}

begin{frame}{First frame}
end{frame}

{
usebackgroundtemplate{animategraphics[autoplay]{1}{animate-test-frames}{}{}}
frame[plain]{}
}% end of usebackgroundtemplate

begin{frame}{Last frame}
end{frame}

end{document}

Note that the correct way for setting a 16:9 aspect ratio for beamer is aspectratio=169, put as document class option. Thus, the animation frames are made with this code:

documentclass[aspectratio=169]{beamer}
begin{document}
{setbeamercolor{background canvas}{bg=red}
begin{frame}
end{frame}
} % end setbeamercolor
end{document}

Answered by AlexG on July 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP