# Logo in a frametitle, metropolis theme

This is the additional question, continuation of my problem given here: How to change the frametitle / footline height in metropolis theme?

I hope that the new post is better to solve a related problem from the comment or auto-ansewring my old question. My explanation is too big here. Please correct me if such method is not accepted here.

Let's start with my MWE. The footline was nicely created for my by @samcarter. Thanks once more.

\documentclass{beamer}

\usetheme[numbering=none,block=fill]{metropolis}

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

\setbeamercolor{footline}{fg=black!2, bg=mDarkTeal}
\setbeamertemplate{frame footer}{My footline}

\makeatletter

\setbeamertemplate{footline}{%
\begin{beamercolorbox}[wd=\textwidth, sep=0.7ex]{footline}% <- default 3ex
\usebeamertemplate*{frame footer}
\hfill%
\usebeamertemplate*{frame numbering}
\end{beamercolorbox}%
}
\makeatother

\begin{document}

\begin{frame}{My frame title}
\begin{block}{Some itemize}
\begin{itemize}
\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}


The Dropbox link to a logo image is here: https://www.dropbox.com/s/z37855vt0f84okd/BM.png?dl=0

How do things look like?

I achieved it by a poorman trick with adding some code to the beamerouterthememetropolis.sty file. Below the appropriate fragment (starting in 90-th line of a file):

\defbeamertemplate{frametitle}{plain}{%
\nointerlineskip%
\begin{beamercolorbox}[%
wd=\paperwidth,%
sep=0pt,%
]{frametitle}%
\metropolis@frametitlestrut@start%
\insertframetitle%
\nolinebreak%
\metropolis@frametitlestrut@end%
\hfill
\includegraphics[height=0.27cm,keepaspectratio]{BM}
\end{beamercolorbox}%
}


Now, how to make this trick work by modifying my MWE only, not by modifying a theme file? I have tried with \addtobeamertemplate command, with no effect.

1. How to adjust the logo image height automatically to the actual font height, not by putting the direct size, but by some command? Look at another screenshot.

1. While the text of a frame title is more or less well vertically centered in a headline, this is not the case in the footline. Is it possible to correct it?

2. Are R:250, G:250, B:250 correct values for a black!2 color? As far as I know black!2 means 2% of black and 98% of white, so the number 0 should be transformed to 0*0.02+255*0.98=249.9, that's why my 250 number. I needed it to make a proper color of my logo.

Many thanks for all people who read this long post up to the end.

• Please don't ask multiple unrelated questions in the same question. Aug 7, 2018 at 11:26
• OK, I will remember. Aug 7, 2018 at 11:28
• I tried to answer all of them which were related to the frametitle. I suggest you move the footline question to a separate question. Aug 7, 2018 at 11:31
• The colour question might be off-topic. Depending on which program you use for your logo, different colour models might come into play... Aug 7, 2018 at 11:32
• If you would convert your logo into something like tikz, you could simply use black!2 as color Aug 7, 2018 at 11:34

Instead of hacking the .sty file (which causes also a problem with the licence), you can add the frame title definition to your .tex file.

To automatically scale it, choose units relative to the font size, e.g. ex.

\documentclass{beamer}

\usetheme[numbering=none,block=fill]{metropolis}

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

\setbeamercolor{footline}{fg=black!2, bg=mDarkTeal}
\setbeamertemplate{frame footer}{My footline}

\makeatletter

\setbeamertemplate{footline}{%
\begin{beamercolorbox}[wd=\textwidth, sep=0.7ex]{footline}% <- default 3ex
\usebeamertemplate*{frame footer}
\hfill%
\usebeamertemplate*{frame numbering}
\end{beamercolorbox}%
}

\setbeamertemplate{frametitle}{%
\nointerlineskip%
\begin{beamercolorbox}[%
wd=\paperwidth,%
sep=0pt,%
]{frametitle}%
\metropolis@frametitlestrut@start%
\insertframetitle%
\nolinebreak%
\metropolis@frametitlestrut@end%
\hfill
\includegraphics[height=1.5ex,keepaspectratio]{example-image-duck}
\end{beamercolorbox}%
}

\makeatother

\begin{document}

\begin{frame}{My frame title}
\begin{block}{Some itemize}
\begin{itemize}
\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}

• Of course, this is the hacking, this was the temporary solution only. I have tried with your method but I added \setbeamertemplate{frametitle}{plain}{ ... } w/o effect. Aug 7, 2018 at 11:26
• Very useful solution. If you want to have the progress bar as in the original template, do not forget to add \usebeamertemplate*{progress bar in head/foot} at the end of the frametitle redefinition, as suggested here: tex.stackexchange.com/a/478214. Jan 5, 2021 at 11:04