[Tex/LaTex] Colored bar above title in LaTeX beamer

beamertemplatesthemes

I wrote an unofficial beamer template for my university. I put the beamer style file and example presentation on github: https://github.com/broesel007/dshsbeamer

Here my question: How can I add a colored bar (e.g. red) above the blue title bar? I also would like to add the logo of our institute in that bar. How can I do that? Any recommendations?

Thank you very much in advance for your help!!

Best Answer

You can set the headline template appropriately. The separation line color allows you to define the background color for the new bar; I set it to myred, where I used

\definecolor{myred}{RGB}{225,0,76}

Of course, use the color that best suits your needs. I also defined a \Ulogo command that allows you to introduce the University logo centered in this bar; the usage of this command is similar to that of \titlegraphic:

\Ulogo{\includegraphics[height=2ex,width=3cm]{<image file>}}

A complete example (since no information was provided about dimensions of the new bar and position of the logo, I used some sensible values, but you can change those according to your needs):

\documentclass{beamer}

\beamertemplatenavigationsymbolsempty

\mode<presentation>
{
  \usetheme{dshsbeamer}
  \setbeamercovered{transparent}
  \setbeamertemplate{items}[circle]
}

\usepackage{fontspec}
\setbeamerfont{frametitle}{size=\LARGE,series=\bfseries}

% color definitions
\usepackage{xcolor}
\definecolor{spohoblue}{RGB}{0, 83, 146}
\definecolor{black}{RGB}{0, 0, 0}

\definecolor{myred}{RGB}{225,0,76}
\setbeamercolor{separation line}{bg=myred}
\newcommand\Ulogo[1]{\def\insertUlogo{#1}}

\makeatletter
\setbeamertemplate{headline}
{
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by\beamer@rightmargin%
  \begin{beamercolorbox}[colsep=1.5pt,wd=\the\@tempdima,ht=4ex,dp=0ex]{separation line}
  \vbox{}\vskip-10pt
  \hfill\insertUlogo\hfill\null
  \vskip0.5ex
  \end{beamercolorbox}%
}
\makeatother

\title[Short title]{An unofficial beamer template for the German Sport University Cologne}
\author[Short author]{Magnus Metz}
\institute[The Institute of Advanced Study]
{Institute of Sport Economics and Sport Management \\
German Sport University Cologne \\
}
\Ulogo{\includegraphics[height=2ex,width=3cm]{example-image-a}}
\date{\today}

\begin{document}

\begin{frame}
\frametitle{First slide}
A test frame
\end{frame}

\end{document}

enter image description here