Currently I am updating and extending my beamer themes. Thereby I also want to solve a spacing problem, which is sometimes quite annoying.
Think of the following example:
\documentclass[t]{beamer}
%
\newcommand{\testcontent}[2]{%
\frametitle{Frame #2}
Text\medskip\par
Itemize:%
\begin{itemize}
\item a%
\item b%
\item c%
\end{itemize}
\begin{figure}
\framebox(300,#1){Height = #1 units}%
\end{figure}
}
%
\begin{document}
%
\begin{frame}
\testcontent{150}{1}%
\end{frame}
%
\begin{frame}
\testcontent{50}{2}%
\end{frame}
%
\begin{frame}
\testcontent{150}{3}%
\vspace{0ex plus 1fil minus 1fil}%
\end{frame}
%
\end{document}
The example creates the following three frames. Open them in separate tabs to see the differences in vertical spacing:
In the first frame the defined height of the figure forces LaTeX to stretch (shrink) the vertical spaces of \medskip
, itemize
and figure
. This can be seen if compared with the second frame, where the height of the figure is smaller and the vertical spaces are not stretched.
So I was looking for a solution to avoid the stretching of vertical spaces and consequently to have no jumping text lines when switching between frames. I found that someone redefined the corresponding lenghts to have no plus minus glue, but this did not work in my case or I missed to change some lengths.
So I came up with the \vspace{0ex plus 1fil minus 1fil}
command in the third frame. This avoids stretching of the other verticals spaces, but gives no warning if the frame content does not fit on the frame. Another problem is, that I have to add this line manually to each frame end. I tried to automate this using \patchcmd
for \beamer@collect@@body
, but this also did not work.
Now to my questions:
- Is there another way to avoid the described stretching of vertical spaces and to have constant vertical spaces independent of the frame content?
- If there is no other solution then I used in the third frame above, is it possible to add the command automatically to each frame end?
Thank you very much for your help.
only<>
command. In your case you could use it in the first frame asonly<1>
for the content of first... thenonly<2>
for the second and 'only<3>' for the third... This works if you really want the above text to be the same for all your 3 frames... If not you can change it too withalt<1>{text for frame 1}{empty or text for others}
etc