1

I've created a beamer environment based on this discussion: Is there a simple command for the available height in a beamer slide? The only issue is that it doesn't work with the overlays. Here is the MWE (to see the error, uncomment the line starting with \only):

\documentclass{beamer}
\usepackage{tikz,environ}

\makeatletter
\NewEnviron{tikzframe}[2][c]{%
\begin{frame}[#1]{#2}
    \global\beamer@shrinktrue
    \gdef\beamer@shrinkframebox{\setbox\beamer@framebox=\vbox to\beamer@frametextheight{
    \begin{tikzpicture}[x=.5\linewidth,y=0.5\beamer@frametextheight]
        \path[use as bounding box] (-1,-1) rectangle (1,1);
        \BODY
    \end{tikzpicture}}}
\end{frame}}

%\NewEnviron{tikzframe}[2][c]{%
%\begin{frame}[#1]{#2}%
%   \begin{tikzpicture}[x=.5\linewidth,y=0.4\paperheight]
%      \path[use as bounding box] (-1,-1) rectangle (1,1);
%      \BODY
%   \end{tikzpicture}
%\end{frame}}

\begin{document}

\begin{tikzframe}{Title}
    \node at (-.5,0) {A};
    \node at (.5,0) {B};
%   \only<2>{\node at (.5,0) {B};}
\end{tikzframe}

\end{document}

do you have ideas what is wrong?

  • 1
    For the overlays to work beamer is trying to find literal \begin,\end{frame} but can't find it since it is buried in the new environment. I doubt there is a solution but who knows. – percusse Oct 22 '17 at 18:11
  • I've updated the code just to show that it may work in principle, but for the commented version of the environment there is no automatic calculation of the textheight... – user54824 Oct 22 '17 at 18:23
  • It seems like in my original MWE giving a frame [shrink] will initialize some macros. In your case you try to apply the third method without the initialization so it fails. I will try to dig out details. – Symbol 1 Oct 22 '17 at 20:52
  • If you add \def\beamer@shrinkfactorinv{1} at the beginning of your document then everything works fine. It is not clear to me what is the meaning of \beamer@shrinkfactorinv while there is another macro called \beamer@shrinkfactor. – Symbol 1 Oct 22 '17 at 21:06
  • Normally beamer generates the frame BEFORE the frame title, which means it cannot compute the height available until after the frame is done. – John Kormylo Oct 22 '17 at 21:20
1

This shows how to compute the frame text height. I used a \rule in place of tikzpicture to simplify matters. Note that it does not leave room for the navigation buttons at the bottom.

\documentclass{beamer}
\usepackage{tikz,environ}
\newlength{\mytextheight}
\makeatletter
\NewEnviron{tikzframe}[2][c]{%
\begin{frame}[#1]{#2}
    \setbox0=\vbox{%
      \vbox{}%
      {\parskip0pt\usebeamertemplate***{frametitle}\vskip0.25em}%
    }%
    \setlength{\mytextheight}{\dimexpr\textheight-\ht0-\dp0}%
    \rule{\linewidth}{\mytextheight}
\end{frame}}
\makeatother

\begin{document}

\begin{tikzframe}{Title}
%    \node at (-.5,0) {A};
%    \node at (.5,0) {B};
%   \only<2>{\node at (.5,0) {B};}
\end{tikzframe}

\end{document}

here is the computation as performed by beamer:

  \ifx\beamer@frametitle\@empty%
    \setbox\beamer@frametitlebox=\box\voidb@x%
  \else%
    \setbox\beamer@frametitlebox=\vbox{%
      \vbox{}%
      {\parskip0pt\usebeamertemplate***{frametitle}\vskip0.25em}%
    }%
  \fi%
  \ifbeamer@plainframe%
    \beamer@frametextheight=\paperheight%
  \else%
    \beamer@frametextheight=\textheight%
  \fi%
  \advance\beamer@frametextheight by-\ht\beamer@frametitlebox%
  \advance\beamer@frametextheight by-\dp\beamer@frametitlebox%
  \advance\beamer@frametextheight by-\beamer@frametopskip%
  • Indeed, one can calculate the textheight for a frame in the normal style with the title box. However, the code doesn't account for situations when the title is not present and/or when the plain style is used. – user54824 Oct 23 '17 at 12:54
  • Do you consider that to be a serious possibility? Also it doesn't subtract \beamer@frametopskip or \beamer@framebottomskip (which are always 0pt but could conceivably be changed). – John Kormylo Oct 23 '17 at 15:22

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.