I started switching full-time to Ubuntu (once again) a couple of weeks ago. Turns out, it’s in much better condition than when I last tried it. Anyway, one of the problems was finding a replacement for Powerpoint. I hate creating presentations for classes — in fact, I think they’re counter-productive — but I have no choice for the moment. So, I decided to give LibreOffice Impress a chance. That was an hour of my life down the drain. Finally, I returned to beamer. Of course, I had to write my own theme because I couldn’t use the same theme used by all the rest of the world. To cut this long and boring story short, I tried very hard to find a tutorial on writing beamer themes, couldn’t do so, learned it through experiment and decided to write the tutorial myself. Here is that tutorial.

This is a beamer newbie tutorial, not a LaTeX newbie tutorial. You should be somewhat comfortable with LaTeX before you can understand this stuff. Also, most of the “techniques” I use here will be frowned upon by LaTeX gurus and I know they’re not the “right” approaches but they get the job done and I will be refactoring this when I get time to adopt the best practices. This tutorial just aims to help you write your own themes in the hope that more and more beamer templates will be created and people will stop using the blue rounded-corner-box theme that beamer has become associated with.

Here’s the final result we’re trying to produce. (This is the beamer-tutorial tag on my github project titled latex-templates. Notice that the template in the github tree might have changed since the writing of this tutorial as I’m continually modifying the code to better suit my workflow. I created the beamer-tutorial tag specifically for this tutorial — as the name implies. All links in this tutorials are supposed to point to files in this tag.)

Let’s begin. Firs, get the tutorial files here. Download the beamer-tutorial.zip and extract it.

The two important files are the following:

1. The source file is in: doc-prep-latex/sources/slideset01.tex
2. Include file is in: includes/header-commands.tex

There are three sections that you need to define to get a basic custom beamer template.

1. Title page
3. Footer

Some Pre-requisites

First, we want to define some custom fields that will be used throughout our files. (I know this isn’t the proper method of defining custom fields but it’s the only one I’m comfortable with.) I will refer to github links but you can see the same thing in your downloaded files. In the slideset01.tex file:

\newcommand{\logoimagepath}{../../logos/fastlogo}
\newcommand{\highlightcolor}{DeepSkyBlue3}
\newcommand{\authorname}{Nauman}
\newcommand{\authoremail}{recluze@gmail.com}
\newcommand{\authorweb}{http://csrdu.org/nauman}
\newcommand{\authoraffiliation}{FAST National University of Computer and Emerging Sciences (FAST-NU) \\ Peshawar Campus}
\institute{http://csrdu.org/nauman}
% --------------------------------------
\newcommand{\coursetitle}{Seminar Series on Introduction to Research}
\newcommand{\slidesettitle}{Document Preparation Using \LaTeX2$_\epsilon$}
\newcommand{\slidesetsubtitle}{}
\newcommand{\slidesetnumber}{01}
\usefonttheme{professionalfonts}


Title Page

Let’s begin by looking at how we’ve modified the title page. Notice, first that we’re including the header file just after the definitions above.

\input{../../includes/header-commands}


This will ensure that we have the stuff included in this location. The way I’ve set this up, the title page will get created automatically and the body will start. The code for that can be seen in includes/header-commands.tex:

\begin{document}
{\setbeamertemplate{footline}{}
\begin{frame}
\title{\slidesettitle}
%\subtitle{SUBTITLE}
\author{\footnotesize
\textbf{\authorname}\\ \authoremail \\ {\scriptsize \url{\authorweb}} \\\vspace{12pt}
{\scriptsize \authoraffiliation}\\\vspace{6pt}
{\tiny \textcolor{gray}{\insertdate}}
}
\date{
{\scriptsize \today}
}
\begin{flushright}\includegraphics[width=0.15\textwidth]{\logoimagepath}\end{flushright}
.
.
\begin{flushleft}
\vspace{-1.5cm}{\small \textcolor{\highlightcolor}{\coursetitle}}\\\vspace{2cm}
{\huge \slidesettitle \ifthenelse{\equal{\slidesetsubtitle}{}}%
{}% if #1 is empty
{: \\ {\large \slidesetsubtitle}}% if #1 is not empty
} \\
\vspace{20pt}
\insertauthor
\end{flushleft}
\end{frame}
}
% custom footer after the title


A little explanation of what’s going on here. This should help you customize the theme depending on your needs. The line numbers in code below refer to the actual file. (Refer to the complete file for reference. We’ll be jumping around a bit.)

Line 102 sets the footline (that’s the footer) to empty. This makes the page numbers etc disappear.

Line 103 begins the first frame (slide).

Lines 104-113 set the title and author etc. Pretty basic stuff.

Line 114 inserts the logo. See the pre-reqs section above to see where the logo image comes from.

Lines 117-127 typeset the title of the presentation, author etc. Again, it’s pretty straight-forward if you know a bit of LaTeX. The only complication might be the if statements. It’s basically saying that if we have a non-empty subtitle, put a colon after the title, insert a linebreak and put the subtitle, otherwise, skip the colon and the subtitle.

Line 130 hides the navigation symbols from this point onwards i.e. they won’t appear on slides other than the title.

We have another little fix that we need to do to finish off the title page and that is the definition of the header for it.

So, we have two types of headers: (a) for the title page and (b) for subsequent pages.

The title header gets defined as:

\setbeamertemplate{headline}{%
\hbox{%
\fontsize{5}{5}\selectfont

\end{beamercolorbox}%
}\vspace{-50ex}
}


We basically redefine the headline template to be a a box! It’s a thin, tall box that just sits on the left edge. It’s created using the beamercolorbox environment with 50ex height, 2.25ex width and the color headbarcolor (Line 54). It has no text (Line 56). Finally, we add a -50ex vertical space so that the text that follows will not get displaced because of this box. (Try getting rid of this line to see where the title goes.)

The second headline we need to define is for subsequent pages.

\setbeamertemplate{headline}{%
\hbox{%
\fontsize{5}{5}\selectfont

\end{beamercolorbox}%
}\vspace{-10ex}
}

% greater line spacing for new slides


This very similar to the first headline. The only difference is that the box is much shorter (10ex). Same trick with the negative vertical space. Notice that we have not actually inserted the frame title. Beamer will take care of that automatically for us. We’re just redefining the headline.

We’re also increasing the line spacing for our subsequent slides (Line 145).

Finally, let’s get to the footer.

Footer

The footer is going to be defined using the same technique of placing boxes with some information in them this time.

\setbeamertemplate{footline}{
\begin{tiny}
\setbeamercolor{foot1}{fg=black!70,bg=gray!10}
\setbeamercolor{foot2}{fg=gray,bg=gray!15}
\setbeamercolor{foot3}{fg=gray,bg=gray!10}
\setbeamercolor{foot4}{fg=black!70,bg=gray!20}
\setbeamercolor{foot5}{fg=gray,bg=gray!15}
\setbeamercolor{foot6}{fg=black,bg=gray!20}

% taken from theme infolines and adapted
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.35\paperwidth,ht=2.25ex,dp=1ex,center]{foot1}%
\fontsize{5}{5}\selectfont
\slidesettitle
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.1\paperwidth,ht=2.25ex,dp=1ex,center]{foot2}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.05\paperwidth,ht=2.25ex,dp=1ex,center]{foot3}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.25\paperwidth,ht=2.25ex,dp=1ex,center]{foot4}%
\fontsize{5}{5}\selectfont
\insertshortauthor\ (\authorweb)
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.05\paperwidth,ht=2.25ex,dp=1ex,center]{foot5}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,right]{foot6}%
\end{beamercolorbox}}%
\vskip0pt%
\end{tiny}
\vskip10pt
}


Lines 62-67 define some colors — basically shades of gray.

Linex 71-88 insert some boxes. Most of them are empty and there for design. We do, however, put the slidesettitle with a small fontsize in the first box (Lines 73-74) and the author’s web address in another box (Lines 81-82). We also put the page numbers in the last box (Line 87). If you can get over all the boxes, this is not that complicated.

Finally, we put a vspace (Line 91) at the end to separate the footer from the lower edge of our slide.

Our slides file now works on this theme and every LaTeX command will work as usual. Maybe I should’ve done some renewcommand’s to get a .sty file but that will have to wait for another day. If someone reading this tutorial can help out with that, fork the project on github, make the changes and send me a pull request.

1. i dont have the requisite know how to comment on this article but, if you need to run Microsoft powerpoint in linux then use the following utility, it works like a charm

http://www.playonlinux.com/en/

give it a try

2. Good job sir, can we see the demo?

3. recluze

November 25, 2011 at 9:14 am

You can see the final PDF on github in the beamer-tutorial tag.

4. Do you know how to remove the space of navigation symbols? – not only the navigationsymbols themselves [\setbeamertemplate{navigation symbols}{}]?