0

I don't know why, but on beamer, when the size of the content on the left column changes between two slides, the position of the right column text also change. For example, if you compile the following code, you will see that at each slide, the A on the left column always change its position.

Do you know how to avoid that?

Thanks!

MWE

\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

As default alignment, beamer centres the content vertically. In this particular case the columns environment as a whole is centred. If you add content to the right column, the columns environment becomes taller, thus the position changes to keep it in the centre.

A very easy workaround: use top aligned frames

The a bit more complicate answer: instead of \only, you can use \uncover or \visible to already reserve space for content that will be revealed step by step.

\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}
  • Thank you for the answer. However, I would like to keep the text vertically centered, and because the different frames may not be related, I can't use uncover... Maybe I should try to add a new column of width 0 with a big phantom element inside... – tobiasBora Apr 24 '18 at 23:43
  • @tobiasBora If you know the total height of your content, have a look at the overlayarea environment. – user36296 Apr 24 '18 at 23:46
  • Thank you. Meanwhile, I used the solution with 3 columns, and it works great, but the need of content height is an issue that is quite long to solve so the code is quite big. With overlayarea the problem would be the same, and also it's not possible (or I did not find the good way to proceed) to vertically center a text in an overlayarea. However, someone tells that it's good to use \parbox instead, see my answer for how to use it. – tobiasBora Apr 25 '18 at 0:11
0

I have a first solution, which is a bit verbose because it needs first this [great code][1] and then it adds a third empty column, but for now it's the best I can do. I'll also look at overlayarea as proposed by samcarter.

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

Edit: Here is the same thing, but with \parbox instead. The code has the same length because the "hard" part is to guess the height, and that code is needed in both solutions.

\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.