66

In Beamer, I often use a two-column slide layout, picture on the left and text on the right. Sometimes the same picture is used on multiple slides, with the text on the right changing. I use the Beamer columns environment for this purpose.

My problem is that typically the pictures in the two slides do not have the same vertical alignment, causing a slightly annoying "jiggle". None of the various options for column seems to help, and the default (align centers) is the most reasonable anyway.

Is there a way to force the picture to be vertically centered with respect to the page, irrespective of the size of the content of the other column?

Here's an example - the text on the left (representing a picture) moves a little between frames.

\documentclass{beamer}
\usepackage{calc}
\begin{document}
\begin{frame}\frametitle{Test frame}
    \begin{columns}
        \column{.5\textwidth}
          A figure
        \column{.5\textwidth}
          \begin{itemize}
              \item Item 1
              \item Item 2
          \end{itemize}
      \end{columns}
\end{frame}
\begin{frame}\frametitle{Test frame 2}
    \begin{columns}
        \column{.5\textwidth}
          A figure
        \column{.5\textwidth}
          \begin{itemize}
              \item Another item 1
              \item Another item 2
              \item This list is longer
              \item Than the previous one
              \item was
          \end{itemize}
      \end{columns}
\end{frame}
\end{document}
Stefan Kottwitz
  • 231,401
Neil Olver
  • 4,942

4 Answers4

97

I had similar problem and found out that it is enough to start the columns environment command by [T] options,

\begin{columns}[T]

Works fine for me.

Stefan Kottwitz
  • 231,401
Jaro
  • 971
  • 1
  • 6
  • 2
32

You could fix the vertical alignment by using minipages of the same height in the second column. Here's the modified example with a stable left column:

\documentclass{beamer}
\usepackage{calc}
\begin{document}
\begin{frame}\frametitle{Test frame}
    \begin{columns}
        \column{.5\textwidth}
          A figure
        \column{.5\textwidth}
          \begin{minipage}[c][.6\textheight][c]{\linewidth}
            \begin{itemize}
                \item Item 1
                \item Item 2
            \end{itemize}
          \end{minipage}
      \end{columns}
\end{frame}
\begin{frame}\frametitle{Test frame 2}
    \begin{columns}
        \column{.5\textwidth}
          A figure
        \column{.5\textwidth}
          \begin{minipage}[c][.6\textheight][c]{\linewidth}
            \begin{itemize}
                \item Another item 1
                \item Another item 2
                \item This list is longer
                \item Than the previous one
                \item was
            \end{itemize}
          \end{minipage}
      \end{columns}
\end{frame}
\end{document}
Stefan Kottwitz
  • 231,401
  • Actually, one more question. Rather than .6\textheight, I'd like to use a value which is always large enough (so that I can use this in a macro). It seems that textheight is too large; does Beamer have a variable that stores the height of the text area of the slide? – Neil Olver Aug 17 '10 at 00:43
  • 4
    I guess it's \beamer@frametextheight in beamerbaseframe.sty. – Stefan Kottwitz Aug 17 '10 at 01:19
  • 4
    Thanks! For the benefit of those not used to @ (which is special), you can use the following sequence to define a \frametextheight, which you can then use in place of .6\textheight in the above.

    \makeatletter\let\frametextheight\beamer@frametextheight\makeatother

    – Neil Olver Aug 17 '10 at 02:00
23

It is also possible to center contents of columns vertically with the [c] options. It works fine for me. Maybe this helps also to solve your problem.

\begin{columns}[c]
pluton
  • 16,421
johnq
  • 231
  • 2
  • 2
7

I think this is a good candidate for the overprint environment. It typesets different material on different slides, but puts them all inside a box the size of the largest one.

\documentclass{beamer}
\usepackage{calc}
\begin{document}
\begin{frame}
    \frametitle<1>{Test frame}
    \frametitle<2>{Test frame 2}
    \begin{columns}
        \column{.5\textwidth}
          A figure
        \column{.5\textwidth}
        \begin{overprint}
          \onslide<1>
          \begin{itemize}
              \item Item 1
              \item Item 2
          \end{itemize}
          \onslide<2>
          \begin{itemize}
              \item Another item 1
              \item Another item 2
              \item This list is longer
              \item Than the previous one
              \item was
          \end{itemize}
        \end{overprint}
      \end{columns}
\end{frame}
\end{document}

EDIT: although, I just realized that this makes both lists be top-aligned, so the shorter one may look a bit displaced. I'm not sure if there's a way to specify that the contents of overprint should be vertically centered.

David Z
  • 12,084
  • 7
  • 48
  • 65
  • Thanks for the suggestion. For various reasons I prefer to keep the frames separate, but that's interesting that you can use overlays with frametitle, I didn't know that! – Neil Olver Aug 17 '10 at 00:36