1

In my beamer presentation, I have three images and a merged pdf that I want to animate using the animate package. The set up is as follows: the three images are lined up next to each other, and I want to replace the third image with the animation. That is, on the first slide, I want the three images to be next to each other, and on the second slide, I want the left two images to be next to the animation (so the animation is replacing the third image).

Here is a picture:

enter image description here

Here is a MWE to show what I tried to do:

\documentclass[8pt]{beamer}

\usetheme{Luebeck}
\usefonttheme{serif}
\setbeamertemplate{itemize item}{\color{black} $\vcenter{\hbox{\tiny$\bullet$}}$} %style of item
\setbeamertemplate{footline}[frame number]{}
\setbeamertemplate{navigation symbols}{}

\usepackage{xcolor}
\usepackage{graphicx}
\setlength{\parskip}{0.75em}
\usepackage{animate}
\usepackage{tikzsymbols}

\begin{document}

\begin{frame}

\begin{figure}
    \centering
    \includegraphics<1->[width = 0.33\textwidth]{cont_lasso.pdf}
    \includegraphics<1->[width = 0.33\textwidth]{cont_ridge.pdf}
    \includegraphics<1>[width = 0.33\textwidth]{cont_enet.pdf}
    \animategraphics<2>[autoplay, loop, width = 0.33\textwidth]{30}{enet_ani_merged}{}{}
\end{figure}

The \textit{shape} of the penalty can give some idea of the type of shrinkage imposed on the model.
\begin{itemize}
    \item Sharp corners $\to$ sparsity! \Laughey[1.5][yellow][pink]
    \item Round corners $\to$ only shrinkage!
\end{itemize}

\end{frame}

\end{document}

The file names of the three images are cont_lasso.pdf, cont_ridge.pdf, and cont_enet.pdf, and the name of the merged pdf for the animation is enet_ani_merged.pdf.

EDIT

For clarification, I want to make it such that the animation automatically starts playing when I begin the second slide.

After some experimentation, it seems my issue is because putting the animategraphics command inside a figure environment is not allowed, and not because of the overlays. So I now want to know, how am I able to put the two graphics and the animation in the same environment?

  • It is possible with the ocgx2 package to make the third image a link that when clicked activates the animation. – AndréC Aug 3 at 20:17
  • @AndréC I will look into that, but I should have mentioned that I want the animation to start playing as soon as I press the clicker to start the next slide. I will update the question with this info. – Aiden Kenny Aug 4 at 6:11
  • 1
    Can't you just remove the figure environment as well as the overlay specifications from the \includegraphics commands? – leandriis Aug 4 at 7:21
  • @leandriis that works for me! Even though I don't need it here, just out of curiosity, do you know if there is a way you can add a caption to this? I put them in a center environment. – Aiden Kenny Aug 4 at 7:57
  • Maybe \captionof from the caption package. – leandriis Aug 4 at 7:57
1

Going off of leandriis comment, here is the code for anyone who would like to see what the final output looks like. I had to add noframenumbering so the frame number does not change.

\documentclass[8pt]{beamer}

\usetheme{Luebeck}
\usefonttheme{serif}
\setbeamertemplate{itemize item}{\color{black} $\vcenter{\hbox{\tiny$\bullet$}}$} %style of item
\setbeamertemplate{footline}[frame number]{}
\setbeamertemplate{navigation symbols}{}

\usepackage{xcolor}
\usepackage{graphicx}
\setlength{\parskip}{0.75em}
\usepackage{animate}
\usepackage{tikzsymbols}

\begin{document}

\begin{frame}{Contour plots}

\begin{figure}
    \centering
    \includegraphics[width = 0.33\textwidth]{cont_lasso.pdf}
    \includegraphics[width = 0.33\textwidth]{cont_ridge.pdf}
    \includegraphics[width = 0.33\textwidth]{cont_enet.pdf}
    %\animategraphics[autoplay, loop, width = 0.33\textwidth]{30}{enet_ani_merged}{}{}
\end{figure}

The \textit{shape} of the penalty can give some idea of the type of shrinkage imposed on the model.
\begin{itemize}
    \item Sharp corners $\to$ sparsity! \Laughey[1.5][yellow][pink]
    \item Round corners $\to$ only shrinkage!
\end{itemize}

\end{frame}

\begin{frame}[noframenumbering]{Contour plots}

\begin{figure}
    \centering
    \includegraphics[width = 0.33\textwidth]{cont_lasso.pdf}
    \includegraphics[width = 0.33\textwidth]{cont_ridge.pdf}
    %\includegraphics[width = 0.33\textwidth]{cont_enet.pdf}
    \animategraphics[autoplay, loop, width = 0.33\textwidth]{30}{enet_ani_merged}{}{}
\end{figure}

The \textit{shape} of the penalty can give some idea of the type of shrinkage imposed on the model.
\begin{itemize}
    \item Sharp corners $\to$ sparsity! \Laughey[1.5][yellow][pink]
    \item Round corners $\to$ only shrinkage!
\end{itemize}

\end{frame}

\end{document}

Here is a screenshot of the output (I could not find a way to screen record the pdf, the right figure is meant to be moving):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.