6

Using beamer when I change a font size in a frame title line and/or footline to the preferred height, the height of these lines is not automatically adjusted to the font height. How to achieve that effect?

I started to use the metropolis theme.

As I was asked, I created a MWE now. BTW, what is the name of a standard color of a frametitle?

\documentclass{beamer}

\usetheme[numbering=none]{metropolis}

\setbeamerfont{frametitle}{size=\normalsize,series=\bfseries}
\setbeamerfont{frametitle}{size=\small,series=\normalfont}

\setbeamercolor{footline}{bg=black!80,fg=white}
\setbeamertemplate{frame footer}{A footline}

\begin{document}

\begin{frame}{A frame title in a small size}
 \begin{block}{Some itemize}
  \begin{itemize}
   \item Item 1
   \item Item 2
  \end{itemize}
 \end{block}
 \begin{block}{Some maths}
 \[\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{\pi^2}{6}=\zeta(2)\]
\end{block}
\end{frame}

\end{document}
4
  • 1
    can you make a minimal working example (MWE)? Commented Aug 6, 2018 at 20:28
  • In a moment. :-)
    – szw1710
    Commented Aug 6, 2018 at 20:31
  • 1
    The easy question first: the default colours for the frametitle in the metropolis theme are fg=black!2, bg=mDarkTeal Commented Aug 6, 2018 at 21:03
  • Of course, it works. You are right, my question is not so easy. I was not able to solve a problem by myself. I have spend at least 2 hours to try and look for a solution in the earlier posts.
    – szw1710
    Commented Aug 6, 2018 at 21:07

1 Answer 1

6

Taking the font size into account will only marginally influence the height of the frametitle. Most of height is determined by the padding around the font and is hard coded in the metropolis theme. However you can adjust the numbers as in the following example.

\documentclass{beamer}

\usetheme[numbering=none]{metropolis}

\setbeamerfont{frametitle}{size=\small,series=\normalfont}
\setbeamercolor{footline}{bg=black!80,fg=white}
\setbeamertemplate{frame footer}{A footline}

\makeatletter
\setlength{\metropolis@frametitle@padding}{1.6ex}% <- default 2.2 ex

\setbeamertemplate{footline}{%
  \begin{beamercolorbox}[wd=\textwidth, sep=1.5ex]{footline}% <- default 3ex
    \usebeamerfont{page number in head/foot}%
    \usebeamertemplate*{frame footer}
    \hfill%
    \usebeamertemplate*{frame numbering}
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

\begin{frame}{A frame title in a small size}
 \begin{block}{Some itemize}
  \begin{itemize}
   \item Item 1
   \item Item 2
  \end{itemize}
 \end{block}
 \begin{block}{Some maths}
 \[\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{\pi^2}{6}=\zeta(2)\]
\end{block}
\end{frame}

\end{document}

enter image description here


If you are using the moloch theme, an updated fork of metropolis, you can adjust the padding around the frame title like this:

\documentclass{beamer}

\usetheme[numbering=none]{moloch}% modern fork of the metropolis theme

\setbeamerfont{frametitle}{size=\small,series=\normalfont}
\setbeamercolor{footline}{bg=black!80,fg=white}
\setbeamertemplate{frame footer}{A footline}

\makeatletter
\setbeamertemplate{frametitle}{%
  \nointerlineskip%
  \begin{beamercolorbox}[%
      wd=\paperwidth,%
      sep=0.5ex,% <- change here (default 1.1ex)
      leftskip=0.5ex,%
      rightskip=\the\glueexpr 0.5ex plus 1fill\relax,%
    ]{frametitle}%
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-0.4ex%
    \strut\insertframetitle\nolinebreak\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
        \else%
        {\usebeamerfont{framesubtitle}\vspace{-0.8ex}\usebeamercolor[fg]{framesubtitle}\strut\insertframesubtitle\strut\par}%
      \fi
    }%
  \end{beamercolorbox}%
  \usebeamertemplate*{progress bar in head/foot}
}

\setbeamertemplate{footline}{%
  \begin{beamercolorbox}[wd=\textwidth, sep=1.5ex]{footline}% <- default 3ex
    \usebeamerfont{page number in head/foot}%
    \usebeamertemplate*{frame footer}
    \hfill%
    \usebeamertemplate*{frame numbering}
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

\begin{frame}
 \frametitle{A frame title in a small size}
 \begin{block}{Some itemize}
  \begin{itemize}
   \item Item 1
   \item Item 2
  \end{itemize}
 \end{block}
 \begin{block}{Some maths}
 \[\sum_{n=1}^{\infty}\frac{1}{n^2}=\frac{\pi^2}{6}=\zeta(2)\]
\end{block}
\end{frame}

\end{document}

enter image description here

2
  • Thank you very much for a nice solution with an explanation. Of course this works excellently.
    – szw1710
    Commented Aug 6, 2018 at 21:31
  • +1: Exactly what I was looking for. Commented Jun 16, 2022 at 4:16

You must log in to answer this question.

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