178

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.

233
+250

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.

  • 6
    Basically the reason to not going deeper with it is: launch time. ;) – Claudio Fiandrino Nov 24 '13 at 12:16
  • 27
    ...........Wow. – marczellm Nov 24 '13 at 13:01
  • I think in this case it is better to use \setbeamertemplate every time instead of \defbeamertemplate*. – marczellm Nov 25 '13 at 10:19
  • @marczellm: why? If you have to create themes from scratch I believe it is better go with \defbeamertemplate. – Claudio Fiandrino Nov 25 '13 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. – Claudio Fiandrino Aug 19 '15 at 9:24
65

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

  • Looks more like a comment to me ;-) You could add at least some images of your themes … – Tobi Nov 29 '13 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.