4

I wrote a custom beamer style. The frame titles height is larger than the standard one. Due to this the frame moves downward over the foot-line and the lower border.

How can I correct the frame height to stay between frame-title and foot-line using \defbeamertemplate or similar?

An example presentation

\documentclass[10pt,aspectratio=169]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\usetheme{mwe}

\author{an Author}
\title{a Title}
\subtitle{a subtitle}
\date{\today}

%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{title}
\begin{tikzpicture}
\draw [very thick] (0,0)rectangle(\textwidth,\textheight);
\end{tikzpicture}
\end{frame}

\end{document}

beamerthememwe.sty

\mode<presentation>

\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

% Settings
\useoutertheme{mwe}

\mode<all>

beamerouterthememwe.sty

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox[]
            (0,0)rectangle(\textwidth+0.5\paperwidth-0.5\textwidth,.135\paperheight);
        \node [ anchor=east,
        font=\LARGE,
        black,
        minimum height=10pt,
        align=center]
            at (current bounding box.east)
            {\textbf{\insertframetitle}};
    \end{tikzpicture}
    \vspace*{5pt}
}


\defbeamertemplate*{footline}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox [draw] (0,\the\textheight) -- (\the\paperwidth,\the\textheight);

        \node [anchor=south west, font=\tiny, black]
            at ($(current bounding box.west)+(5pt,0)$)
            {\insertauthor};

        \node [anchor=south, font=\tiny, black]
            at (current bounding box)
            {\insertdate};

        \node [anchor=south east, font=\tiny, black]
            at ($(current bounding box.east)+(-5pt,0)$)
            {\insertframenumber/\inserttotalframenumber};

        \draw [double distance = 0.6pt, line cap=round,color=black]
            ($(current bounding box.west)+(5pt,11pt)$) --
            ($(current bounding box.east)+(-5pt,11pt)$);

    \end{tikzpicture}
}
\mode<all>

This is the output: The big frame shows the dimension of the frame-area.

enter image description here


\newcommand*{\BlockImage}[3]
{
   \begin{column}{#1\textwidth}
   \begin{block}{\footnotesize #2}
      \centering
      \includegraphics[width=\textwidth,
                       height=.75\beamer@frametextheight,
                       keepaspectratio]{#3}
   \end{block}
   \end{column}
}

final workaround

\makeatletter
\newlength{\frameheadheight}
\setlength{\frameheadheight}{2cm}
\newlength{\frametextheight}
\setlength{\frametextheight}{\paperheight}
\addtolength{\frametextheight}{-\footheight}
\addtolength{\frametextheight}{-\headheight}
\addtolength{\frametextheight}{-\frameheadheight}
\makeatother

\newcommand*{\BlockImg}[3]
{
   \begin{column}{#1\textwidth}
   \vskip-.5\frameheadheight
   \begin{block}{\footnotesize #2}
      \centering
      \includegraphics[%width=\textwidth,
                       height=.75\frametextheight,
                       keepaspectratio]{#3}
   \end{block}
   \end{column}
}
Alex44
  • 573
  • 6
  • 18
  • 2
    Can you please make a MWE? – samcarter_is_at_topanswers.xyz Mar 05 '18 at 14:35
  • 1
    your code fragments do not compile and reproducing your problem without a lot of guesswork is impossible. – samcarter_is_at_topanswers.xyz Mar 05 '18 at 14:47
  • Oh, that is normal. \textheight only factors in the footline and the headline, not the frametitle. What do you need the textheight for? – samcarter_is_at_topanswers.xyz Mar 05 '18 at 15:12
  • It scales the boxes and all the other stuff. I mean i.e. an itemize will not shrink because it runs over the footer first. – Alex44 Mar 05 '18 at 15:15
  • See https://tex.stackexchange.com/q/368710/36296 and the questions marked as duplicates for some methods how to access the actual remaining space of the frame. – samcarter_is_at_topanswers.xyz Mar 05 '18 at 15:18
  • Is there no way to do this within the style definition? Something like textheight=pageheight-framtitleheight-footlineheight... – Alex44 Mar 05 '18 at 15:33
  • Would be possible but would not solve your problem. – samcarter_is_at_topanswers.xyz Mar 05 '18 at 15:40
  • I.e. my graphics height are calculated with \includegraphics[width=\textwidth,height=.75\textheight]{img.png}`. What shal I use instead? – Alex44 Mar 05 '18 at 15:45
  • [your image will be distorted - you are missing keepaspectratio]. If you really must define your image with two lengths use one of these: https://tex.stackexchange.com/questions/278429/is-there-a-simple-command-for-the-available-height-in-a-beamer-slide https://tex.stackexchange.com/questions/262815/automatically-fit-the-graphics-in-the-remaining-space-of-a-beamer-slidehttps://tex.stackexchange.com/questions/44218/set-image-to-full-all-available-space-in-beamer-without-overlapping-other-eleme – samcarter_is_at_topanswers.xyz Mar 05 '18 at 15:51
  • yes of course - but it seems not logical to me while \textheight is defined as "The height of text on the page" and it is not really this way here on beamer... (https://en.wikibooks.org/wiki/LaTeX/Lengths) And it would be the best to shrink the size of the frame globally so that this value is correct for all possible usages. The other stuff looks like workarounds and makes it difficult to handle. Which value defines the height of the frame? – Alex44 Mar 05 '18 at 16:09
  • I once thought like this too, but after a bit of thinking the current definition textheight is as good as it can be. The framtitle has no constant height, it can vary from slide to slide within the same frame, so paper - head - foot is really the last constant thing to take. (the wikibook is no reliable reference work, it is wrong in so many places) – samcarter_is_at_topanswers.xyz Mar 05 '18 at 16:18
  • ok on my case these are constant values per design - not per LaTeX as you explained. May I need to find a nicer way to calculate this heights... This approach https://tex.stackexchange.com/questions/368710/beamer-how-to-get-height-for-frame-content goes in the right direction but it based on the full frame but I only want to get it run for a box inside a column. Please see the post... – Alex44 Mar 05 '18 at 16:22
  • I figured out, that \headheight is zero. This makes the calculation wrong! – Alex44 Mar 05 '18 at 16:59
  • Of course headheight is zero, you don't have a headline – samcarter_is_at_topanswers.xyz Mar 05 '18 at 17:00
  • Headline is not to understand as frame title height? Is there an extra value for? – Alex44 Mar 05 '18 at 17:02
  • headheight is for the height of the headline, which is not the frametitle. – samcarter_is_at_topanswers.xyz Mar 05 '18 at 17:03
  • There is no saved value of the frametitle height, you can either measure it yourself or simply use a hard coded value if it is not gonna change (as in my second answer below) – samcarter_is_at_topanswers.xyz Mar 05 '18 at 17:04
  • Yes. I do it similar like this... Many thanks for your help and you patience – Alex44 Mar 05 '18 at 17:06

1 Answers1

1

The problem that your itemize did not shrink above the footline is totally unrelated to the frametitle or the textheight. The problem is that your footline has zero height. If you increase the height of the footline, the items will shrink above it:

\documentclass[10pt,aspectratio=169]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox[]
            (0,0)rectangle(\textwidth+0.5\paperwidth-0.5\textwidth,.135\paperheight);
        \node [ anchor=east,
        font=\LARGE,
        black,
        minimum height=10pt,
        align=center]
            at (current bounding box.east)
            {\textbf{\insertframetitle}};
    \end{tikzpicture}
    \vspace*{5pt}
}


\defbeamertemplate*{footline}{mwe}[1][]
{
        \vskip1.8\baselineskip
    \begin{tikzpicture}
        \useasboundingbox [draw] (0,\the\textheight) -- (\the\paperwidth,\the\textheight);

        \node [anchor=south west, font=\tiny, black]
            at ($(current bounding box.west)+(5pt,0)$)
            {\insertauthor};

        \node [anchor=south, font=\tiny, black]
            at (current bounding box)
            {\insertdate};

        \node [anchor=south east, font=\tiny, black]
            at ($(current bounding box.east)+(-5pt,0)$)
            {\insertframenumber/\inserttotalframenumber};

        \draw [double distance = 0.6pt, line cap=round,color=black]
            ($(current bounding box.west)+(5pt,11pt)$) --
            ($(current bounding box.east)+(-5pt,11pt)$);

    \end{tikzpicture}
}
\mode<all>

\author{an Author}
\title{a Title}
\subtitle{a subtitle}
\date{\today}

%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{title}
\begin{itemize}
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\end{itemize}
\end{frame}

\begin{frame}{title}
\begin{itemize}
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\item t
\end{itemize}
\end{frame}

\end{document}

For creating some height to scale images:

\documentclass[10pt,aspectratio=169]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{mwe}[1][]
{
    \begin{tikzpicture}
        \useasboundingbox[]
            (0,0)rectangle(\textwidth+0.5\paperwidth-0.5\textwidth,.135\paperheight);
        \node [ anchor=east,
        font=\LARGE,
        black,
        minimum height=10pt,
        align=center]
            at (current bounding box.east)
            {\textbf{\insertframetitle}};
    \end{tikzpicture}
    \vspace*{5pt}
}


\defbeamertemplate*{footline}{mwe}[1][]
{
        \vskip1.8\baselineskip
    \begin{tikzpicture}
        \useasboundingbox [draw] (0,\the\textheight) -- (\the\paperwidth,\the\textheight);

        \node [anchor=south west, font=\tiny, black]
            at ($(current bounding box.west)+(5pt,0)$)
            {\insertauthor};

        \node [anchor=south, font=\tiny, black]
            at (current bounding box)
            {\insertdate};

        \node [anchor=south east, font=\tiny, black]
            at ($(current bounding box.east)+(-5pt,0)$)
            {\insertframenumber/\inserttotalframenumber};

        \draw [double distance = 0.6pt, line cap=round,color=black]
            ($(current bounding box.west)+(5pt,11pt)$) --
            ($(current bounding box.east)+(-5pt,11pt)$);

    \end{tikzpicture}
}
\mode<all>

\makeatletter
\newlength{\myheight}
\setlength{\myheight}{\paperheight}
\addtolength{\myheight}{-\footheight}
\addtolength{\myheight}{-\headheight}
\addtolength{\myheight}{-1.95cm}
\makeatother

\author{an Author}
\title{a Title}
\subtitle{a subtitle}
\date{\today}

%%% DOCUMENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}{title}
\begin{tikzpicture}
\draw [very thick] (0,0)rectangle(\textwidth,\myheight);
\end{tikzpicture}

\end{frame}

\end{document}