12

To keep content from jumping between slides in a beamer presentation, I would like to use an overlayarea environment. By trial and error, one can determine the appropriate amount of space to reserve. However, I would like to determine it automatically. To do this, I want to determine the height of one or more block environments.

In the following example, the position of "Some text" changes between the first and second slides. I would like for it not to move. To that end, I would like to enclose Block 1 and Block 2 in an overlayarea. I want to determine the heights of Block 1 and Block 2, as well as the vertical space between them, and then use that as the height parameter for the overlayarea.

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{Frankfurt}
}

\begin{document}

\begin{frame}
 Some text

 \only<1>{
  \begin{block}{Block 1}
   Other text
  \end{block}

  \begin{block}{Block 2}
   Still more text
  \end{block}
}

  \only<2>{
    \begin{block}{Block 3}
     Yet more text
    \end{block}
}
\end{frame}

\end{document}

This is what I want to end up with:

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{Frankfurt}
}

\begin{document}

\begin{frame}
 Some text

 \begin{overlayarea}{\textwidth}{\myheight} %\myheight is the quantity to be determined
   \only<1>{
  \begin{block}{Block 1}
   Other text
  \end{block}

  \begin{block}{Block 2}
   Still more text
  \end{block}
}

  \only<2>{
    \begin{block}{Block 3}
     Yet more text
    \end{block}
}
 \end{overlayarea}
\end{frame}

\end{document}

N.B.: This question is about how to find the width of a block, but I have not found anything about finding the height.

0

2 Answers 2

9
+50

You can do it by boxing the content and then adding the depth and height of the box to obtain the total height:

\setbox0=\vtop{%
  \begin{block}{Block 1}
   Other text
  \end{block}%
}
\setlength{\myheight}{\ht0}%
\addtolength{\myheight}{\dp0}%

enter image description here

Code:

\documentclass{beamer}

\mode<presentation>
{
  \usetheme{Frankfurt}
}

\newlength{\myheight}
\begin{document}
\setbox0=\vtop{%
  \begin{block}{Block 1}
   Other text
  \end{block}%
}
\setlength{\myheight}{\ht0}%
\addtolength{\myheight}{\dp0}%

\begin{frame}
 Some text

 \begin{overlayarea}{\textwidth}{\myheight} %\myheight is the quantity to be determined
   \only<1>{
  \begin{block}{Block 1}
   Other text
  \end{block}

  \begin{block}{Block 2}
   Still more text
  \end{block}
}

  \only<2>{
    \begin{block}{Block 3}
     Yet more text
    \end{block}
}
 \end{overlayarea}
\end{frame}

\end{document}
1

Instead of write \only command out of the block you should write \uncover or \visible command into the block. In this way latex will reserve enough space.

In your example, I do not clearly understand which block you want to keep fixed.

1
  • I want "Some text" to stay still. I've edited my question to reflect that. Commented Nov 6, 2012 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .