253

No matter how hard I search, I cannot find any information on creating a Beamer theme from scratch, as opposed to LEGOing it together from the built-in inner, outer and color themes, maybe modifying one or two beamer templates by using cryptic commands without explanation.

The reason I want to do this is that none of the built-in inner, outer and color themes suit my taste. All of them are instantly recognisable as Beamer, and there is very small visual change between them.

What I would like to implement is something along the lines of certain PowerPoint templates: powerpoint template 1 powerpoint template 2

and I would also like to port the beautiful powerdot themes (see gallery), such as the KlopeSpring theme to Beamer, as Powerdot is very inconvenient for having to convert all images to EPS.

So how do I go about all those geometric decorations and placing text above/below/on them? Oh, and I almost forgot to mention that I know about the easy solution of "include an empty slide PDF as background image", but that is no fun.

3

3 Answers 3

324
+750

Build your own theme: no one forces you to exploit predefined inner, outer, color and font themes. Look at this theme: is it instantly recognisable as Beamer ?

But, let's have a practical example: it is one hour-built theme, thus take it just for demonstration. Lot of improvements can be done. The reference is one of your pictures.

We call this new theme texsx mainly due to the fact that I don't have much fantasy with names. So in a directory we create the following files:

  1. beamercolorthemetexsx.sty
  2. beamerinnerthemetexsx.sty
  3. beamerouterthemetexsx.sty
  4. beamerthemetexsx.sty
  5. texsx-example.tex

To build the theme we might exploit TikZ: very likely you can avoid it, but the question has the magic tag, so I felt almost obligated (even if the true reason is: with TikZ was faster ;) ).

So we keep beamerthemetexsx.sty very simple:

\mode<presentation>

% Requirement
\RequirePackage{tikz}

% Settings
\useinnertheme{texsx}
\useoutertheme{texsx}
\usecolortheme{texsx}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]  

\mode<all>

we load the themes, remove the navigation symbols and define blocks aspect.

Now, let's start define the title page in the inner theme. As we need to test what we're doing, at first is is better to set up the example document:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\title{There Is No Largest Prime Number}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{euclid@alexandria.edu}}

\usetheme{texsx}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\end{document}

Nothing is strange or difficult till now. Time to build the titlepage; I would proceed as follows:

  • exploit the background template to set the titlepage background
  • define a title page template in which the title, the author and the date are actually set.

The operations described are translated in beamerinnerthemetexsx.sty in the following way:

\mode<presentation>

\setbeamertemplate{background}{
  \begin{tikzpicture}
  \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
  \fill[color=brown] (0,2) rectangle (\the\paperwidth,\the\paperheight);
  \fill[color=orange] (0,0) rectangle(2.95,1.9);
  \fill[color=blue!50!cyan!80] (3.05,0) rectangle(\the\paperwidth,1.9);
  \ifnum\thepage>1\relax%
   \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
   \fi
  \end{tikzpicture}
}

% Title page
\defbeamertemplate*{title page}{texsx}[1][]
{ 
   \vskip6cm%
    \begin{beamercolorbox}[wd=12cm,leftskip=3cm,sep=8pt,#1]{title page header}
      \usebeamerfont{title}\inserttitle\par%
    \end{beamercolorbox}%
    \vskip0.75cm%
    \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{author}
      \usebeamerfont{author}\insertauthor%
    \end{beamercolorbox}
     \vskip0.2cm%
    \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{date}
      \usebeamerfont{author}\insertdate%
    \end{beamercolorbox}
  \vfill
}

\mode
<all>

It is important to notice that we define ourself the bounding box through \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight); then, thanks to the test on the page number, we apply the background on the title page only.

In the title page template then we actually put the elements mentioned above. We characterize their color aspect passing to beamercolorboxes title page header, author, date so we need these definitions. Let's add them to the beamercolorthemetexsx.sty:

\mode<presentation>

% Settings
\setbeamercolor*{title page header}{fg=white}
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}

\mode
<all>

Now, if we compile our example we get:

enter image description here

Cool!

Let's going on defining the aspect of the frame title. This is done with a template called frametitle in the beamerouterthemetexsx.sty, which looks like:

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{texsx}[1][]
{
\vskip1cm%
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle} 
  \begin{tikzpicture}
  \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1.2);
  \fill[orange] (0,0) rectangle(2.95,1.2);
  \fill[blue!50!cyan!80] (3.05,0) rectangle(\the\paperwidth,1.2);
   \ifx\insertframesubtitle\@empty%
      {\node[anchor=west, white,font=\large] at (3.2,0.61){\insertframetitle};}
      \else%
      {\node[anchor= west, white,font=\large] at (3.2,0.81){\insertframetitle};%
       \node[anchor= west, white,font=\small] at (3.2,0.41){\insertframesubtitle};}%
      \fi
  \end{tikzpicture}
  \end{beamercolorbox}
}

\mode<all>

Basically, we exploit the same concept of the titlepage to draw some boxes; then we check whether the subtitle is present: accordingly we set the position of title and subtitle or we set only the frame title with TikZ nodes.

We need again tests to verify our idea. So let's add something on our example:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\title{There Is No Largest Prime Number}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{euclid@alexandria.edu}}

\usetheme{texsx}

\begin{document}

\begin{frame}
\titlepage
\end{frame}


\begin{frame} 
\frametitle{There Is No Largest Prime Number} 
\framesubtitle{The proof uses \textit{reductio ad absurdum}.} 
\begin{theorem}
There is no largest prime number. \end{theorem} 
\begin{enumerate} 
\item<1-| alert@1> Suppose $p$ were the largest prime number. 
\item<2-> Let $q$ be the product of the first $p$ numbers. 
\item<3-> Then $q+1$ is not divisible by any of them. 
\item<1-> But $q + 1$ is greater than $1$, thus divisible by some prime
number not in the first $p$ numbers.
\end{enumerate}
\end{frame}

\begin{frame}{A longer title}
\begin{itemize}
\item one
\item two
\end{itemize}
\end{frame}

\end{document}

As we also have lists, we have to define their aspect and color. So we need to add:

\setbeamercolor*{item}{fg=orange}

in our beamercolorthemetexsx.sty and:

% Items
\setbeamertemplate{items}[square]
\setbeamertemplate{sections/subsections in toc}[square]

in beamerinnerthemetexsx.sty. It is not mandatory to put the latter definitions in the inner theme, but I followed the Beamer style.

It seems to me we can compile our document; the result is:

enter image description here

Ok, I agree: the colors are not the ones in the reference picture and the subtitle is not perfectly aligned with the title (this is due to the font size difference), but the new theme is here.

15
  • 9
    Basically the reason to not going deeper with it is: launch time. ;) Nov 24, 2013 at 12:16
  • 41
    ...........Wow.
    – marczellm
    Nov 24, 2013 at 13:01
  • I think in this case it is better to use \setbeamertemplate every time instead of \defbeamertemplate*.
    – marczellm
    Nov 25, 2013 at 10:19
  • @marczellm: why? If you have to create themes from scratch I believe it is better go with \defbeamertemplate. Nov 25, 2013 at 10:39
  • 1
    @macmadness86: I use that both for the background and frametitle to be sure not having objects that being large might cause problems to the page. Using a path would not provide cropping facilities. Aug 19, 2015 at 9:24
83

Using Claudio's answer as a starting point, I developed two themes which I made available here, one based on the PowerPoint Median theme and one based on the Powerdot KlopeSpring theme. There may be more to come.

In addition to the techniques Claudio demonstrated, I used the textpos package to do absolute positioning of text on the page.

In order to achieve different frame backgrounds on section pages and plain frames, I used something like

\newcommand{\sectionframe}{{
    \setbeamertemplate{background}{
      % draw the different background
    }
    \setbeamertemplate{headline}{}
    \frame{\sectionpage}
}}

Note the double curly brackets; the inner pair puts everything in a group and thus keeping the template changes local.

Here are some images:

sample slides

0
5

For those of you trying to use a background image behind the title, you can adapt the great answer of Claudio to obtain something like this:

enter image description here

This is for instance my beamerinnerthemeubuntu.sty (for the page title), where ubuntu-background.jpg is my image.

\mode<presentation>


% Title page
\defbeamertemplate*{title page}{ubuntu}[1][]
{ 
  \begin{tikzpicture}[overlay, remember picture]
    \node[inner sep=0pt,outer sep=0pt,anchor=north east] at (current page.north east)
    {\includegraphics[width=\the\paperwidth,height=\the\paperheight]{ubuntu-background.jpg}};
  \end{tikzpicture}
    \vskip2cm%
    %% "title page header"  defines the loaded colors.
    \begin{beamercolorbox}[center,sep=8pt,#1]{title page header}
      \usebeamerfont{title}\huge\inserttitle\par%
    \end{beamercolorbox}%
    \vskip0.75cm%
    \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{author}
      \usebeamerfont{author}\textcolor{white}{\insertauthor}%
    \end{beamercolorbox}
     \vskip0.2cm%
    \begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{date}
      \usebeamerfont{author}\textcolor{white}{\insertdate}%
    \end{beamercolorbox}
  \vfill
}

\mode
<all>

and my outer theme (for the pages):

\mode<presentation>

% Frame title
\defbeamertemplate*{frametitle}{ubuntu}[1][]
{%
  \begin{tcolorbox}[enhanced,sharp corners,spread upwards,frame hidden,boxrule=0pt,interior style tile={width=\paperwidth}{ubuntu-background.jpg},before skip=0pt,halign=center]
    \usebeamercolor{frametitle}\color{fg}
    \insertframetitle
  \end{tcolorbox}
}

\mode<all>

and my beamerthemeubuntu.sty

% https://tex.stackexchange.com/questions/146529/design-a-custom-beamer-theme-from-scratch
\mode<presentation>

% Requirement
\RequirePackage{tikz}
\usetikzlibrary{positioning,calc}
\RequirePackage{graphicx}

\RequirePackage[sfdefault]{noto}
\RequirePackage[T1]{fontenc}
\RequirePackage[most]{tcolorbox}

% Settings
\useinnertheme{ubuntu}
\useoutertheme{ubuntu}
\usecolortheme{ubuntu}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]  

\mode<all>

together with my beamercolorthemeubuntu.sty (to configure the colors):

\mode<presentation>

% Settings
\setbeamercolor*{title page header}{fg=white}
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{item}{fg=black}
\setbeamercolor*{frametitle}{fg=white}
\mode
<all>

You may also like to use:

\begin{tcolorbox}[enhanced,title=My title, frame style tile={width=\paperwidth}{ubuntu-background.jpg}]
    Hello
\end{tcolorbox}

to create something like:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .