LaTeX Beamer + Columns: Change Image in one column

6.4k views Asked by At

I want a slide with two columns. Left is a single bullet, right two examples how to compute a the function given on the left:

\begin{frame}{Example Protocol}
\begin{columns}
\begin{column}{.49\textwidth}   
\begin{itemize}
    \item Consider the function: 
        \begin{align*}
            &f: \{0, 1\}^2 \times \{0, 1\}^2 \to \{0, 1\},\\
            &f(x, y) = \left\lbrace
                \begin{array}{cl}
                1, & \text{if } x_1 = y_1 \text{ or } y_2 = 1\\ 
                0, & \text{else.}
                \end{array} 
            \right.
        \end{align*}\pause
\end{itemize}
\end{column}

\begin{column}{.49\textwidth}
\only<2>{
\begin{figure}
    \centering
    \input{figs/bp1s.tex}
\end{figure}
}\pause
\only<3>{
\begin{figure}
    \centering
    \input{figs/bp2s.tex}
\end{figure}
}
\end{column}
\end{columns}
\end{frame}

My issue: In this setup the item on the left moves down one line when I go the next overlay. I can avoid this by using \onslide instead of \only, but this will result in another problem as the first image blocks the whole space on the right and the second image diappears "out of bounds" while the visible part of the right column on overlay 3 is empty.

Do you have a proper way to handle this?

Best, Niklas

1

There are 1 answers

1
samcarter_is_at_topanswers.xyz On BEST ANSWER

There are several possibilities to avoid this problem. For example

Approach 1:

One way is to place your image in an overlayarea of sufficient width and height to accommodate the biggest of your images

\documentclass{beamer}

\begin{document}

\begin{frame}{Example Protocol 1}
\begin{columns}
\begin{column}{.65\textwidth}   
\begin{itemize}
    \item Consider the function: 
        \begin{align*}
            &f: \{0, 1\}^2 \times \{0, 1\}^2 \to \{0, 1\},\\
            &f(x, y) = \left\lbrace
                \begin{array}{cl}
                1, & \text{if } x_1 = y_1 \text{ or } y_2 = 1\\ 
                0, & \text{else.}
                \end{array} 
            \right.
        \end{align*}
\end{itemize}
\end{column}
\begin{column}{.3\textwidth}
\begin{overlayarea}{\textwidth}{.45\textheight}
\only<2>{%
\begin{figure}
%    \centering
    \rule{.5\textwidth}{.4\textheight}
\end{figure}
}%\pause
\only<3>{%
\begin{figure}
%    \centering
    \rule{.5\textwidth}{.2\textheight}
\end{figure}
}
\end{overlayarea}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[t]{Example Protocol 2}
\begin{columns}[T]
\begin{column}{.65\textwidth}   
\begin{itemize}
    \item Consider the function: 
        \begin{align*}
            &f: \{0, 1\}^2 \times \{0, 1\}^2 \to \{0, 1\},\\
            &f(x, y) = \left\lbrace
                \begin{array}{cl}
                1, & \text{if } x_1 = y_1 \text{ or } y_2 = 1\\ 
                0, & \text{else.}
                \end{array} 
            \right.
        \end{align*}
\end{itemize}
\end{column}
\begin{column}{.3\textwidth}
\only<2>{%
\begin{figure}
%    \centering
    \rule{.5\textwidth}{.4\textheight}
\end{figure}
}%\pause
\only<3>{%
\begin{figure}
%    \centering
    \rule{.5\textwidth}{.2\textheight}
\end{figure}
}
\end{column}
\end{columns}
\end{frame}


\end{document}

enter image description here

Approach 2:

Or top align your frame and columns

\documentclass{beamer}

\begin{document}

\begin{frame}[t]{Example Protocol 2}
\begin{columns}[T]
\begin{column}{.65\textwidth}   
\begin{itemize}
    \item Consider the function: 
        \begin{align*}
            &f: \{0, 1\}^2 \times \{0, 1\}^2 \to \{0, 1\},\\
            &f(x, y) = \left\lbrace
                \begin{array}{cl}
                1, & \text{if } x_1 = y_1 \text{ or } y_2 = 1\\ 
                0, & \text{else.}
                \end{array} 
            \right.
        \end{align*}
\end{itemize}
\end{column}
\begin{column}{.3\textwidth}
\only<2>{%
\begin{figure}
%    \centering
    \rule{.5\textwidth}{.4\textheight}
\end{figure}
}%\pause
\only<3>{%
\begin{figure}
%    \centering
    \rule{.5\textwidth}{.2\textheight}
\end{figure}
}
\end{column}
\end{columns}
\end{frame}


\end{document}

enter image description here