How to Create a Beamer Template — A Newbie’s Tutorial

Update: If you are interested in getting a concise intro to LaTeX along with my tips on best practices, checkout my course (for just $12.99) on Udemy here.

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 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
  2. Header and
  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:

[sourcecode lang=”latex” firstline=”12″] newcommand{logoimagepath}{../../logos/fastlogo}
newcommand{authoraffiliation}{FAST National University of Computer and Emerging Sciences (FAST-NU) \ Peshawar Campus}
% ————————————–
newcommand{coursetitle}{Seminar Series on Introduction to Research}
newcommand{slidesettitle}{Document Preparation Using LaTeX2$_epsilon$}

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.

[sourcecode lang=”latex” firstline=”28″] 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:

[sourcecode lang=”latex” firstline=”101″] begin{document}
textbf{authorname}\ authoremail \ {scriptsize url{authorweb}} \vspace{12pt}
{scriptsize authoraffiliation}\vspace{6pt}
{tiny textcolor{gray}{insertdate}}
{scriptsize today}
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
} \
% custom footer after the title
%setbeamertemplate{navigation symbols}{tiny textcolor{gray}{coursetitle [Slideset slidesetnumber] – }textcolor{black}{insertframenumber / inserttotalframenumber}}
setbeamertemplate{navigation symbols}{}

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.

Header for Slides

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

The title header gets defined as:

[sourcecode lang=”latex” firstline=”51″] setbeamertemplate{headline}{%


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.

[sourcecode lang=”latex” firstline=”134″] setbeamertemplate{headline}{%


% 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.


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

[sourcecode lang=”latex” firstline=”60″] setbeamertemplate{footline}{

% taken from theme infolines and adapted
insertshortauthor (authorweb)
insertframenumber{} / inserttotalframenumber hspace*{2ex}

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.

Some Comments
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.

Tags: No tags

5 Responses

Add a Comment

Your email address will not be published. Required fields are marked*