[Tex/LaTex] beamer: Create own headline theme

beamerthemes

I'd like to create a custom LaTeX beamer theme like the one in the snapshot below which I took from a presentation whose source code I do not have. Nevertheless, I'd like to reproduce these results on my own and thereby learn how to better customize LaTeX beamer.

enter image description here

In this example, "Introduction" is the first section and "The questions" is a sub-section. The black headline background fades into the gray canvas (or is it a shadow?).

It would be great if you could provide me with the correct code. I've tried myself for hours, but haven't gotten further than adjusting the background canvas color.

Best Answer

You can redefine the headline, footline and frametitle templates; something along these lines:

\documentclass{beamer}

\definecolor{secinhead}{RGB}{249,196,95}
\definecolor{titlebg}{RGB}{51,51,51}

\setbeamercolor{secsubsec}{fg=secinhead,bg=black}
\setbeamercolor{frametitle}{fg=secinhead,bg=titlebg}

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=8.25ex,dp=3.5ex]{secsubsec}%
    \raggedright
    \hspace*{2em}%
    {\sffamily\Large\color{secinhead}\thesection.~\insertsection\hfill\insertsubsection}%
    \hspace*{2em}%
  \end{beamercolorbox}%
  }%
}
\setbeamertemplate{frametitle}
{\vskip-3pt
  \leavevmode
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.8ex,dp=1ex]{frametitle}%
    \raggedright\hspace*{2em}\small\insertframetitle
  \end{beamercolorbox}
  }%
}
\setbeamertemplate{footline}{}

\begin{document}

\section{Introduction}
\subsection{The questions}
\begin{frame}\frametitle{A test frame}Test\end{frame}
\subsection{Another questions}
\begin{frame}\frametitle{Another test frame}Test\end{frame}

\end{document}

enter image description here

Note however that probably you will have to redefine also some other templates to mantain consistency; for example, which color/font to use to display the frame title? which color for enumerated lists?

Another option, this time the frametitle will have to be given another definition:

\documentclass{beamer}

\definecolor{secinhead}{RGB}{249,196,95}
\definecolor{shadowbg}{RGB}{51,51,51}

\setbeamercolor{secsubsec}{fg=secinhead,bg=black}
\setbeamercolor{shadow}{fg=secinhead,bg=shadowbg}

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=8.25ex,dp=3.5ex]{secsubsec}%
    \raggedright
    \hspace*{2em}%
    {\sffamily\Large\color{secinhead}\thesection.~\insertsection\hfill\insertsubsection}%
    \hspace*{2em}%
  \end{beamercolorbox}%
  }\vskip0pt%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.8ex,dp=1ex]{shadow}%
  \mbox{}
  \end{beamercolorbox}
  }%
}
\setbeamertemplate{frametitle}{}
\setbeamertemplate{footline}{}

\begin{document}

\section{Introduction}
\subsection{The questions}
\begin{frame}Test\end{frame}
\subsection{Another questions}
\begin{frame}Test\end{frame}

\end{document}

enter image description here

Here's the code producing the vertical shading color for the second vertical "bar":

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{shadings}
\definecolor{secinhead}{RGB}{249,196,95}
\definecolor{shadowbg}{RGB}{51,51,51}

\setbeamercolor{secsubsec}{fg=secinhead,bg=black}
\setbeamercolor{shadow}{fg=secinhead,bg=shadowbg}

\setbeamertemplate{headline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=8.25ex,dp=3.5ex]{secsubsec}%
    \raggedright
    \hspace*{2em}%
    {\sffamily\Large\color{secinhead}\thesection.~\insertsection\hfill\insertsubsection}%
    \hspace*{2em}%
  \end{beamercolorbox}%
  }\vskip-1pt%
  \hbox{%
  \tikz\draw[draw=none,top color=black,bottom color=shadowbg!60] (0,0) rectangle (\paperwidth,0.5);
  }%
}
\setbeamertemplate{frametitle}{}
\setbeamertemplate{footline}{}

\begin{document}

\section{Introduction}
\subsection{The questions}
\begin{frame}
Test
\end{frame}

\end{document}

and here's the upper part of the resulting frame:

enter image description here

Of course, change the values for top color, and bottom color according to your needs (you can even select a middle color value).

Related Question