4

I am usually not a fan of animations in scientific presentations, but here I am asking how to implement one.

I have two plots, with the second one (figure B below) being a close-up version of the first one (figure A below). I implemented this using the columns environment and onslide numbers:

\documentclass{beamer}

\usetheme{boxes}

\usepackage[export]{adjustbox}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.pathreplacing,angles,quotes,decorations.pathmorphing}

\begin{document}

\begin{frame}{Hello}
    \framesubtitle{I like trains}
    \begin{columns}
        \column{0.5\linewidth}
            \centering
            \begin{tikzpicture}
                \onslide<1->{
                    \draw[<->] (-0.8,0) -- (0.8,0);
                }
            \end{tikzpicture}
        \column{0.5\linewidth}
            \includegraphics<1>[width=\textwidth]{example-image-a}
            \includegraphics<2>[width=\textwidth]{example-image-b}
    \end{columns}
\end{frame}

\end{document}

Now when I go through the presentation this is really confusing, since we see figure A and then directly the super close-up version figure B without knowing which part of A it shows. Ideally I would like to have a simple "zooming effect". I thought the easiest option would be to insert a number of intermediate overlays betwee figure A and B, and then let them transition into each other with a certain pause time. However I don't know how to implement this without having to click through all of them. Any help on this or alternative implementations would be much appreciated.

2 Answers2

3

How about this snippet?

\documentclass{beamer}

\usetheme{boxes}

\usepackage[export]{adjustbox}

\usepackage{tikz,animate}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.pathreplacing,angles,quotes,decorations.pathmorphing}

\begin{document}

\begin{frame}{Hello}
\animate<2-51>
\newcount\mysize
\animatevalue<2-42>{\mysize}{12}{52}
\transduration<2-42>{0.4}
    \framesubtitle{I like it when it rains}
    \begin{columns}
        \column{0.5\linewidth}
            \centering
            \begin{tikzpicture}
                \onslide<1->{
                    \draw[<->] (-0.8,0) -- (0.8,0);
                }
            \end{tikzpicture}
        \column{0.5\linewidth}
        \begin{tikzpicture}
        \node at (0,0) {\includegraphics[width=6cm]{example-image-a}};
        \pause
        \node at (0,0) {\includegraphics[width=\the\mysize mm]{example-image-b}};
        \end{tikzpicture}
    \end{columns}
\end{frame}

\end{document}

This produces a beamer animation that zooms the second picture in at the center of the first one, but by adjusting the position of the second node you can control this position.

enter image description here

And I should mention that the animation only works when certain requirements are met. I use the fullscreen mode of acroread. (And the \transduration<2-42>{0.4} command allows you to adjust the speed.)

  • Great, this works perfectly! Below I add a slightly modified version of the answer here, combining your approach with the following answer https://tex.stackexchange.com/a/53638/96546. – Wolpertinger Jan 10 '18 at 18:34
2

Here is a slightly modified version of @marmot's answer, combining his animation method with this answer. That way one can include a new figure file in each animation step and the "zooming" is contained in what these figures show (they would have to be created externally). This is what I originally intended in the question.

\documentclass{beamer}

\usetheme{boxes}

\usepackage[export]{adjustbox}

\usepackage{tikz,animate}
\usetikzlibrary{shapes,arrows,positioning}
\usetikzlibrary{decorations.pathreplacing,angles,quotes,decorations.pathmorphing}

\begin{document}

    \begin{frame}{Hello}
        \animate<2-9>
        \newcount\mysize
        %\animatevalue<2-42>{\mysize}{12}{52}
        \transduration<2-7>{0.4}
        \framesubtitle{I like it when it rains}
        \begin{columns}
            \column{0.5\linewidth}
            \centering
            \begin{tikzpicture}
            \onslide<1->{
                \draw[<->] (-0.8,0) -- (0.8,0);
            }
            \end{tikzpicture}
            \column{0.5\linewidth}
            \begin{tikzpicture}
            \node at (0,0) {\includegraphics[width=6cm]{example-image-a}};
            \foreach \x in {a,b,a,b,a,b}
            {
                \pause
                \node at (0,0) {\includegraphics[width=6cm]{example-image-\x}};
            }
            \end{tikzpicture}
        \end{columns}
    \end{frame}

\end{document}
  • 1
    Very nice! Note that it is possible to play external animations. That is, if you produce the whole sequence of pictures externally, it might be more efficient to create the full movie and show it. As far as I know, you are then not as restricted in your choice of pdf viewer and mode. –  Jan 10 '18 at 19:52
  • @marmot Interesting idea! I'll check, but I'm almost sure this will be possible in Matplotlib, which I am using anyway. Thanks a lot for the input, much appreciated. – Wolpertinger Jan 10 '18 at 20:22
  • @marmot Following your idea I found cute command for latex: \animategraphics[]{}{}{}{}, which allows to directly create a movie from individual pdf files without the \foreach workaround :) – Wolpertinger Jan 11 '18 at 23:39
  • Thanks a lot for letting me know! (As a marmot, I always enjoy reading messages from a Wolpertinger;-) –  Jan 12 '18 at 02:24
  • @marmot thanks, me too, I know quite a few of your fellow marmots who live just down south in the mountains from where I live ;-) Btw, would you mind having a look at the following question? https://tex.stackexchange.com/questions/410001/bug-in-beamer-animation-and-overlay It is what evolved from our discussion here. Now I have the additional problem that I have to combine this with itemize overlays surrounding the figure and I encountered some strange behaviours. – Wolpertinger Jan 12 '18 at 10:33