# animategraphics is off center in beamer (using animate package)

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:

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

Thanks!

• Your graphic is too large. You should either scale it or set the margins to zero. Jan 26 '20 at 15:08

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}