Beamer:独立列

Beamer:独立列

不知道为什么,在 beamer 上,当两张幻灯片之间左列内容的大小发生变化时,右列文本的位置也会发生变化。例如,如果你编译下面的代码,你会看到在每张幻灯片中,左列的文本A总是改变其位置。

你知道如何避免这种情况吗?

谢谢!

平均能量损失

\documentclass[]{beamer}
\begin{document}

\begin{frame}{Test}
  \begin{columns}
    \begin{column}{.4\textwidth}
      A
    \end{column}
    \begin{column}{.4\textwidth}%
      \only<1>{B}
      \only<2>{C\\D}
      \only<3>{C\\D\\E}
      \only<4>{C\\D\\E\\F}
    \end{column}
  \end{columns}
\end{frame}

\end{document}

答案1

作为默认对齐方式,beamer 将内容垂直居中。在此特定情况下,columns整个环境居中。如果您将内容添加到右列,则列环境会变得更高,因此位置会发生变化以使其保持居中。

一个非常简单的解决方法: 使用顶部对齐框架

答案稍微复杂一点:\only您可以使用 来代替,\uncover以便\visible为将要逐步揭示的内容保留空间。

\documentclass[]{beamer}
\begin{document}

\begin{frame}[t]{Test}
  \begin{columns}
    \begin{column}{.4\textwidth}
      A
    \end{column}
    \begin{column}{.4\textwidth}%
      \only<1>{B}
      \only<2>{C\\D}
      \only<3>{C\\D\\E}
      \only<4>{C\\D\\E\\F}
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}{Test}
  \begin{columns}
    \begin{column}{.4\textwidth}
      A
    \end{column}
    \begin{column}{.4\textwidth}%
      \uncover<1->{B}

      \uncover<2->{C}

      \uncover<3->{D}

      \uncover<4->{E}
    \end{column}
  \end{columns}
\end{frame}

\end{document}

答案2

我有第一个解决方案,它有点冗长,因为它首先需要这个[很棒的代码][1],然后添加第三个空列,但目前这是我能做的最好的。我还会看看overlayareasamcarter 的建议。

\documentclass[]{beamer}

% https://tex.stackexchange.com/questions/44218/set-image-to-full-all-available-space-in-beamer-without-overlapping-other-eleme/44298#44298
% Chate sidebarthemefalse to sidebarthemetrue if you have a sidebar
\newif\ifsidebartheme
\sidebarthemefalse

\newdimen\contentheight
\newdimen\contentwidth
\newdimen\contentleft
\newdimen\contentbottom
\makeatletter
\newcommand*{\calculatespace}{%
    \contentheight=\paperheight%
    \ifx\beamer@frametitle\@empty%
        \setbox\@tempboxa=\box\voidb@x%
      \else%
        \setbox\@tempboxa=\vbox{%
          \vbox{}%
          {\parskip0pt\usebeamertemplate***{frametitle}}%
        }%
        \ifsidebartheme%
          \advance\contentheight by-1em%
        \fi%
      \fi%
    \advance\contentheight by-\ht\@tempboxa%
    \advance\contentheight by-\dp\@tempboxa%
    \advance\contentheight by-\beamer@frametopskip%
    \ifbeamer@plainframe%
    \contentbottom=0pt%
    \else%
    \advance\contentheight by-\headheight%
    \advance\contentheight by\headdp%
    \advance\contentheight by-\footheight%
    \advance\contentheight by4pt%
    \contentbottom=\footheight%
    \advance\contentbottom by-4pt%
    \fi%
    \contentwidth=\paperwidth%
    \ifbeamer@plainframe%
    \contentleft=0pt%
    \else%
    \advance\contentwidth by-\beamer@rightsidebar%
    \advance\contentwidth by-\beamer@leftsidebar\relax%
    \contentleft=\beamer@leftsidebar%
    \fi%
}
\makeatother

\begin{document}


\begin{frame}{Test}
  \begin{columns}
    \begin{column}{.4\textwidth}
      A
    \end{column}
    \begin{column}{.4\textwidth}%
      \only<1>{B}
      \only<2>{C\\D}
      \only<3>{C\\D\\E}
      \only<4>{C\\D\\E\\F}
    \end{column}
    \begin{column}{0pt}
      \calculatespace%
      \vline height 0.95\contentheight
    \end{column}
  \end{columns}
\end{frame}

\end{document}

编辑:这是同样的事情,但用了\parbox相反的方法。代码长度相同,因为“困难”的部分是猜测高度,并且两个解决方案都需要该代码。

\documentclass[]{beamer}

% https://tex.stackexchange.com/questions/44218/set-image-to-full-all-available-space-in-beamer-without-overlapping-other-eleme/44298#44298
\newif\ifsidebartheme
\sidebarthemetrue

\newdimen\contentheight
\newdimen\contentwidth
\newdimen\contentleft
\newdimen\contentbottom
\makeatletter
\newcommand*{\calculatespace}{%
    \contentheight=\paperheight%
    \ifx\beamer@frametitle\@empty%
        \setbox\@tempboxa=\box\voidb@x%
      \else%
        \setbox\@tempboxa=\vbox{%
          \vbox{}%
          {\parskip0pt\usebeamertemplate***{frametitle}}%
        }%
        \ifsidebartheme%
          \advance\contentheight by-1em%
        \fi%
      \fi%
    \advance\contentheight by-\ht\@tempboxa%
    \advance\contentheight by-\dp\@tempboxa%
    \advance\contentheight by-\beamer@frametopskip%
    \ifbeamer@plainframe%
    \contentbottom=0pt%
    \else%
    \advance\contentheight by-\headheight%
    \advance\contentheight by\headdp%
    \advance\contentheight by-\footheight%
    \advance\contentheight by4pt%
    \contentbottom=\footheight%
    \advance\contentbottom by-4pt%
    \fi%
    \contentwidth=\paperwidth%
    \ifbeamer@plainframe%
    \contentleft=0pt%
    \else%
    \advance\contentwidth by-\beamer@rightsidebar%
    \advance\contentwidth by-\beamer@leftsidebar\relax%
    \contentleft=\beamer@leftsidebar%
    \fi%
}
\makeatother

\begin{document}


\begin{frame}{Test}
  \begin{columns}
    \begin{column}{.4\textwidth}
      \calculatespace
      % https://tex.stackexchange.com/questions/83672/beamer-vertically-center-picture-inside-overlayarea
      \parbox[t][\contentheight][t]{\linewidth}{
        A
      }
    \end{column}
    \begin{column}{.4\textwidth}%
      \only<1>{B}
      \only<2>{C\\D}
      \only<3>{C\\D\\E}
      \only<4>{C\\D\\E\\F}
    \end{column}
  \end{columns}
\end{frame}

\end{document}



  [1]: https://tex.stackexchange.com/questions/44218/set-image-to-full-all-available-space-in-beamer-without-overlapping-other-eleme/44298#44298

相关内容