Search code examples
latexoverlaybeamer

Beamer : overlayarea inside a figure?


in my Beamer presentation, I would like to dynamically switch images in a figure environnement. More precisely, my figure contains 9 subfloats presented 3x3 and each of them should switch between two images during the presentation.

In order to avoid some "tilting" between the different elements, I thought that it would be a good idea to use an overlayarea inside each subfloat.

Sadly, when used in an figure environment, the overlayarea seems to behave very odd : every thing I put in it appear outside the overlayarea ??

Here is a very short example :

\documentclass[9pt, aspectratio=43]{beamer}

\usepackage [francais]{babel}
\usepackage [T1]{fontenc}
\usepackage [utf8]{inputenc}

\usepackage[position=top]{subfig}
\usepackage{pdfpages}


\begin{document}

\begin{frame}
%% This works fine : 123 appears INSIDE the overlayarea
\fbox{\begin{overlayarea}{3cm}{2cm}
\fbox{123}
\end{overlayarea}}

%% This looks odd : 456 appears OUTSIDE the overlayarea
\begin{figure}
\fbox{\begin{overlayarea}{3cm}{2cm}
\fbox{456}
\end{overlayarea}}
\end{figure}

\end{frame}

\end{document}

Perhaps I mis-use this environnement ?

Thanks a lot :)

BR

Donut


Solution

  • Quick workaround: warp your subimages in minipages of fixed height:

    \documentclass[9pt, aspectratio=43]{beamer}
    
    \begin{document}
    
    \begin{frame}
    
    \begin{figure}
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    \hfill
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    \hfill
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%%
    \end{minipage}%
    \hfill
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    \hfill
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    \hfill
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    \hfill
    \begin{minipage}[c][.3\textheight][c]{.3\textwidth}
    \centering
    \includegraphics<1>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-9x16}%
    \includegraphics<2>[width=\textwidth,height=.3\textheight,keepaspectratio]{example-image-duck}%
    \end{minipage}%
    \end{figure}
    
    \end{frame}
    
    \end{document}