[Tex/LaTex] Fix positions in minipage environment when using \only

beamergraphicspositioning

I have the following slide

\documentclass[10pt]{beamer}
\usepackage{graphicx}

\begin{document}

\begin{frame}{Title}
Some texts

\begin{figure}
    \begin{minipage}{0.499\linewidth}{
            \centering
            \only<1>{%
                \includegraphics[width=\linewidth]{image1}}%
            \only<2>{%
                \includegraphics[width=\linewidth]{image2}}%            
        }
    \end{minipage}%
    \begin{minipage}{0.499\linewidth}{
            \centering
            \includegraphics[width=\linewidth]{image3}
        }
    \end{minipage}
\end{figure}
Some other texts
\end{frame}

\end{document}

The problem is that image1 and image2 have different heigths (in particoular, image1 is taller) so that the texts above the figures change positions between first & second slide

Is there a way to keep the texts in position as in the first slide?

Best Answer

Try with overlayarea. For example from the beamer user guide "9.5 Dynamically Changing Text or Images":

\begin{overlayarea}{\textwidth}{3cm}
  \only<1>{Some text for the first slide.\\Possibly several lines long.}
  \only<2>{Replacement on the second slide.}
\end{overlayarea}

or simply specify the height of your minipage:

\documentclass[10pt]{beamer}

\begin{document}

\begin{frame}{Title}
Some texts

\begin{figure}
    \begin{minipage}[c][3cm][c]{0.499\linewidth}
    \centering
    \includegraphics<1>[height=3cm]{example-image}
    \includegraphics<2>[height=1cm]{example-image}            
    \end{minipage}%
    \begin{minipage}{0.499\linewidth}
    \centering
    \includegraphics[height=2cm]{example-image}
    \end{minipage}
\end{figure}
Some other texts
\end{frame}

\end{document}