# beamer: Create own headline theme

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.

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.

-

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

\documentclass{beamer}

\definecolor{titlebg}{RGB}{51,51,51}

{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=8.25ex,dp=3.5ex]{secsubsec}%
\raggedright
\hspace*{2em}%
\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}


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}

{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=8.25ex,dp=3.5ex]{secsubsec}%
\raggedright
\hspace*{2em}%
\hspace*{2em}%
\end{beamercolorbox}%
}\vskip0pt%
\hbox{%
\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}


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

\documentclass{beamer}
\usepackage{tikz}

{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=8.25ex,dp=3.5ex]{secsubsec}%
\raggedright
\hspace*{2em}%
\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:

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

-
 I've implemented your snippet and it essentially worked right away. Thanks so much! It has been incredibly helpful. I had intended that the background color for the whole page be dark gray instead of white and figured it out by myself (\setbeamercolor{background canvas}{bg=mydarkgray}, using a color definition by myself). However, what I couldn't work out is the slight vertical gradient/shading from black to darkgray between the headline and the canvas. In simple words, I try to achieve a shadow or a shading underneath the black headline area. If you have an idea,would be glad if you shared ;) – Steve06 Dec 15 '11 at 0:23 @Steve06: I've already updated my answer with an example with the shading. – Gonzalo Medina Dec 15 '11 at 0:57 thanks again for helping out so promptly. However, it's not working for me yet, as I receive the error message "I can't find file tikzlibraryshadings.code.tex'". I installed all the tikz packages (i.e. all packages starting with tikz) manually from the package manager (admin version) of Miktex. – Steve06 Dec 15 '11 at 16:22 @Steve06: the shadings library comes with the latest full version og PGF/TikZ. Which version of MiKTeX do you have installed? – Gonzalo Medina Dec 15 '11 at 16:24 I have Miktex 2.8.3478 – Steve06 Dec 15 '11 at 16:36

Since Gonzalo Medina gave a nice starter for defining the template from scratch, here is a taming the existing themes solution. I also recommend you to go through the existing style codes of beamer mainly because it is very structured and written by the package author himself Till Tantau, thus gives a direct information about the usage.

Before anything note that the themes are stored under the beamer package files and they can be modified and used with changing only the last part of the filename. For example, your desired headline looks like a modification to the outer theme smoothbars, hence I took the beamerouterthemesmoothbars.sty and copied to the folder where the presentation file is. Then, I renamed it to beamerouterthememytheme.sty and modified only the headline part as follows:

                                % Head
{%
\ifbeamer@sb@subsection%
\vskip-9.75ex%
\else%
\vskip-7ex%
\fi%
{\Large \thesection~.\insertsection\hfill\insertsubsection}
\end{beamercolorbox}%
}%


This allows me to use this modified theme in my beamer presentation code as follows:

\documentclass[hyperref={unicode}]{beamer}
\mode<presentation>

\useoutertheme{mytheme}

\definecolor{titlebg}{RGB}{51,51,51}

\title{P\"{O}ANG}
\author{Hawking of IKEA}
\begin{document}
%=================================================
\begin{frame}[plain]\titlepage
\end{frame}
%=====================================================
\section{Introduction}
\begin{frame}{Outline}
\tableofcontents
\end{frame}
%=====================================================
\subsection{Questions}
\begin{frame}{Why?}
\begin{itemize}
\item When?
\item Really?
\end{itemize}
\end{frame}
\begin{frame}{Big bang}
\begin{itemize}
\item Long ago
\item Yes
\end{itemize}
\end{frame}
\end{document}


with all the colors are due to Gonzalo. Here is the output:

Notice that I did a few mistakes here. First of all, the modified template still has residues of smoothbars here and there. The remaining ones are irrelevant style errors like, having the headline a little too high and the section number dot is misplaced etc. I hope I don't offend you if I leave them as they are. You can continue and modify the rest of the templates e.g. inner,color` in a similar fashion.

And sorry for the stupid content, I just wrote whatever I see around me.

-
 your solution was helpful as well, essentially because it taught me how to customize existing themes. However, my knowledge of latex seems insufficient in order to realize what I have in mind via this route. I find it particularly hard because as a newbie you do not know what the default definitions are that have been set in some other file and that you need to override to achieve the desired results. – Steve06 Dec 15 '11 at 0:26 No worries. I feel exactly the same as you do when I am dealing with these. But the main reason for my answer was to get the shading (or shadows, which can be tricky) and doing this taming method you get it right away. And also you just see how people do things. Gathering some courage, you might soon start fiddling with the "gibberish" code and the learning would start from there. Good luck :) – percusse Dec 15 '11 at 0:31