Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted
+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}
share|improve this answer
add comment

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.

share|improve this answer
    
I want "Some text" to stay still. I've edited my question to reflect that. –  Andrew Uzzell Nov 6 '12 at 13:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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