[Tex/LaTex] Subsection size in header doesn’t change header height

beamerfontsizeheader-footer

I want to change the font size of section and subsection titles in the header. It works fine for the section title, the header automatically increases its height (as stated in the beamer manual) but if I try the same thing with the subsection, I get following result.

Subsection height problem

Is there any way to set the subsection title's block height so the large subsection title fits?

I don't need that box to be of exact size, as I probably create a background using tkiz anyway. So if setting the size isn't possible, is there some way to just move the title it down a little bit?

\documentclass{beamer}
\setbeamerfont*{section in head/foot}{size=\huge}
\setbeamerfont*{subsection in head/foot}{size=\huge}
\usetheme{Berlin} 

\begin{document}
    \section{Section 1}
    \subsection{Subsection 1}
    \begin{frame}{Frame}
        Content
    \end{frame}
\end{document}

I get the same output when I try \subsection{\huge Subsection 1} instead of \setbeamerfont*.

Best Answer

The Berlin theme uses internally the miniframes outer theme; this outer theme explicitly sets the height of the color box used for the subsection in head/foot as 2.5ex, and its depth as 1.125ex. A change in the size font for the subsections won't therefore increase the height and depth of this box and will produce the undesired effect you noticed.

To change this behaviour, one can make the height and depth of this box font size-aware, by setting their values according to the height and depth of some appropriate characters with the desired font size, as I did in my example code below.

Notice also that I changed the order of \usetheme and \setbeamerfont so you don't have to declare the font size inside \subsection:

\documentclass[compress]{beamer}
\usetheme[]{Berlin} 
\setbeamerfont*{section in head/foot}{size=\huge}
\setbeamerfont*{subsection in head/foot}{size=\huge}

\newlength\SubHt
\settoheight\SubHt{\usebeamerfont{subsection in head/foot}S}
\newlength\SubDh
\settodepth\SubDh{\usebeamerfont{subsection in head/foot}g}

\makeatletter
\setbeamertemplate{headline}
{%
  \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
  \end{beamercolorbox}
  \begin{beamercolorbox}{section in head/foot}
    \vskip2pt\insertnavigation{\paperwidth}\vskip2pt
  \end{beamercolorbox}%
  \ifbeamer@theme@subsection%
    \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
    \end{beamercolorbox}
    \begin{beamercolorbox}[ht=1.5\SubHt,dp=1.5\SubDh,%defaults: ht=2.5ex,  dp=1.125ex
      leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
      \usebeamerfont{subsection in head/foot}\insertsubsectionhead
    \end{beamercolorbox}%
  \fi%
  \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
  \end{beamercolorbox}
}
\makeatother

\begin{document}
    \section{Section 1}\subsection{Subsection g1}
    \begin{frame}{Frame}
        Content    
    \end{frame}
\end{document}

enter image description here