LaTeX Beamer + Columns:更改一列中的图片

3

我想要一个带有两列的幻灯片。左侧是一个单个的项目符号,右侧是两个示例,说明如何计算左侧给出的函数:

\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}

我的问题:在这种设置中,当我切换到下一个覆盖层时,左侧的项目会向下移动一行。我可以通过使用\onslide而非\only来避免这个问题,但这会导致另一个问题,因为第一张图片会阻挡右边的整个空间,而第二张图片则“超出范围”而在第三个覆盖层的可见部分为空白。
你有适当的方法来处理这个问题吗?
最好的祝愿, 尼克拉斯

“bp1s.tex”和“bp2s.tex”生成的图像大小不同吗?即便如此,我也无法复制你的问题。 - Werner
这似乎是朝着正确的方向迈出的一步。这两个文件都只包含tikz代码。生成的图形大小不同,将较小的文件插入一个虚拟节点可以使它们的大小相等。我还有一个与第一层重合且大小相同但右侧为空的空白tikz图片。虽然左侧仍然有轻微移动,但不像在 http://tex.stackexchange.com/questions/44630/beamer-only-with-columns-makes-things-move-down 中描述的那样糟糕。这对我来说非常有效,但如果有人找到更好的解决方案,我会很高兴。 - ttnick
1个回答

6

有几种可能的方法可以避免这个问题。例如

方法一:

一种方法是将您的图像放置在足够宽和高的overlayarea中以容纳您最大的图像。

\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}

方法二:

或者将框架和列顶部对齐

在此输入图片描述

\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


@ttnick 感谢你的赞美之词! - samcarter_is_at_topanswers.xyz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接