1

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}
\setbeamerfont{page number in head/foot}{size=\normalsize,series=\normalfont\bfseries}

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

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

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

\begin{document}

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

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

How do things look like?

enter image description here

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,%
      leftskip=\metropolis@frametitle@padding,%
      rightskip=\metropolis@frametitle@padding,%
    ]{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.

Few additional questions.

  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.

enter image description here

  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.

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

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}
\setbeamerfont{page number in head/foot}{size=\normalsize,series=\normalfont\bfseries}

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

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

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

\setbeamertemplate{frametitle}{%
  \nointerlineskip%
  \begin{beamercolorbox}[%
      wd=\paperwidth,%
      sep=0pt,%
      leftskip=\metropolis@frametitle@padding,%
      rightskip=\metropolis@frametitle@padding,%
    ]{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 \alert{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}
| improve this answer | |
  • 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. – szw1710 Aug 7 '18 at 11:26

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.