ComputersMake your own beamer style: ducks!

It is that moment in time when someone (maybe yourself!) decide it’s time to change the style of the presentations… and they send you a (more or less) nice PowerPointTM  template.

Obviously, you want it in LaTeX — to use all your nice math or TikZ drawing: let’s see how can design your beamer theme from square one.

 

The needed reference is the Beamer manual, of course; then start (like me) from this nice post; and of course, you need the fun TikZducks package by samcarter.  Also invaluable is this nice cheat sheet.

I will post here two files: the first one is the style itself, heavily commented to help you adapt it (if you change all the ducks with your images, and twiddle the colors, you can have very different styles); the second one is how to use the style for an example presentation.

%
% Code by Romano Giannetti, (c) 2019
% This code is distributable with one of the following licences:
% CC-BY 4.0 https://creativecommons.org/licenses/by/4.0/
% LPPL https://www.latex-project.org/lppl/
%
% The code is heavily based on:
% https://tex.stackexchange.com/questions/146529/design-a-custom-beamer-theme-from-scratch
% https://tex.stackexchange.com/questions/26299/how-does-beamer-build-the-frame
% ...and several other ideas on tex.stackexchange.com
%
% Thanks to @marmot, @samcarter, @Raaja and @JouleV for very useful hints...
%
\RequirePackage{ragged2e}
\RequirePackage{array}
\RequirePackage{booktabs}
\RequirePackage{xifthen}
\RequirePackage[absolute,overlay]{textpos}
\RequirePackage{tikz}
\RequirePackage{tikzducks}
% \usepackage[absolute,overlay,showboxes]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
%% the next line will superimpose a grid that you can use to
%%
%% commands to set several elements in the presentation
%%
\newcommand{\ducks@toptitlepage}{}
\newcommand{\ducks@leftabove}{}
\newcommand{\ducks@leftbelow}{}
\newcommand{\ducks@rightabove}{}
\newcommand{\ducks@rightbelow}{}
\newcommand{\ducks@bgduckopacity}{0.2}
 \newcommand{\toptitlepage}[1]{\renewcommand{\ducks@toptitlepage}{#1}}
\newcommand{\leftabove}[1]{\renewcommand{\ducks@leftabove}{#1}}
\newcommand{\leftbelow}[1]{\renewcommand{\ducks@leftbelow}{#1}}
\newcommand{\rightabove}[1]{\renewcommand{\ducks@rightabove}{#1}}
\newcommand{\rightbelow}[1]{\renewcommand{\ducks@rightbelow}{#1}}
\newcommand{\bgduckopacity}[1]{\renewcommand{\ducks@bgduckopacity}{#1}}
%
\usetheme{default}
% colors
\providecolor{ducksazul}{RGB}{33,82,191}
% \providecolor{ducksamarillo}{RGB}{215,188,10}
\colorlet{ducksamarillo}{yellow!50!orange}
\providecolor{ducksgris}{RGB}{97,87,82}
\providecolor{ducksrojo}{RGB}{192,10,32}
 %% color scheme
\setbeamercolor{alerted text}{fg=ducksrojo}
\setbeamercolor{structure}{fg=ducksazul}
 \setbeamercolor{palette primary}{fg=ducksazul,bg=ducksamarillo!70}
\setbeamercolor{palette secondary}{fg=ducksazul,bg=ducksamarillo!80}
\setbeamercolor{palette tertiary}{fg=ducksazul,bg=ducksamarillo!90}
\setbeamercolor{palette quaternary}{fg=ducksgris}%, bg=ducksamarillo}
 \setbeamercolor{titlelike}{parent=palette quaternary}
 \setbeamercolor{block title}{fg=ducksazul,bg=ducksamarillo}
\setbeamercolor{block title alerted}{use=alerted text,fg=ducksazul,bg=alerted text.fg!75!bg}
\setbeamercolor{block title example}{use=example text,fg=ducksazul,bg=example text.fg!75!bg}
 \setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!25!bg}
\setbeamercolor{block body alerted}{parent=normal text,use=block title alerted,
bg=block title alerted.bg!25!bg}
\setbeamercolor{block body example}{parent=normal text,use=block title example,
bg=block title example.bg!25!bg}
 \setbeamercolor*{separation line}{}
\setbeamercolor*{fine separation line}{}
 \setbeamercolor{date in head/foot}{fg=ducksgris}
\setbeamercolor{title in head/foor}{fg=black}
 %% fonts
 \usefonttheme[onlymath]{serif}
\setbeamerfont{description item}{series=\bfseries}
\setbeamerfont{tile in head/foot}{series=\bfseries}
 %% lists and outlines
 \setbeamertemplate{section in toc}[sections numbered]
\setbeamertemplate{subsection in toc}[subsections numbered]
 %% duck boxes
\newsavebox{\bigduck}
\savebox{\bigduck}{\tikz[scale=4]\begin{scope}[transparency group] \duck\end{scope};}
\newsavebox{\horducks}
\savebox{\horducks}{%
\tikz[scale=0.3] \duck[body=ducksazul] \duck;
\tikz[scale=0.3] \duck[body=ducksamarillo] \duck;
\tikz[scale=0.3] \duck[body=ducksrojo] \duck;
}
%% overlays
 \setbeamercovered{invisible}
% \setbeamercovered{transparent}
 % The original template requires a left-shift frame. I don't like it, but well...
 \newlength{\left@shift}\setlength{\left@shift}{2cm}
\newlength{\tmp@l}
\newlength{\tmp@w}
\setbeamersize{text margin left=\the\left@shift}%
 %
% The normal logo is on top right side. Embedded in the frametitle so that you can
% switch it off with a simple \frametitle{}
%
\setbeamertemplate{frametitle}{%
\begin{textblock*}{1.6cm}(0.2cm,0.2cm)
\tikz[scale=0.6] \duck[body=ducksazul];
\end{textblock*}
\vspace*{0.3cm}
\insertframetitle \par
{\small \insertframesubtitle\par}
}
%
% The standard background has a very transparent image in it. The problem here is
% that how visible it is depend on the gamma of the display, so make it configurable.
%
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth,\the\paperheight);
\fill[white] (0,0) rectangle (\the\paperwidth,\the\paperheight);
\ifbeamer@plainframe % no bg for plain frames
\else
\ifnum\thepage>1\relax
\node[anchor=south east, opacity=\ducks@bgduckopacity] at (\the\paperwidth, 0pt)
{\usebox{\bigduck}};
\fi
\fi
\end{tikzpicture}%
}
%
% This is a bit of magic numbers hit and miss. It works at least in 4:3, 16:9, 16:10, 3:2
% Title slide must have [plain] to suppress footline
%
\setbeamertemplate{title page}{%
\begin{tikzpicture}[box/.style={% draw=red, % for debug
text width=\the\tmp@w, align=left, anchor=north west,
}]
\useasboundingbox (0,0) rectangle (0.9*\the\paperwidth-\the\left@shift, \the\paperheight-5pt);
\fill [color=ducksamarillo] (\the\paperwidth/3-\the\left@shift, \the\paperheight/3) rectangle (\the\paperwidth,\the\paperheight);
\fill [color=ducksgris] (\the\paperwidth/3-\the\left@shift, -5pt) rectangle (\the\paperwidth,\the\paperheight/3);
% \node [draw, circle, inner sep=0.5cm] at (\the\paperwidth/3-\the\left@shift, \paperheight/2) {}; % for debug
\pgfmathsetlength{\tmp@l}{-\left@shift+0.5*(\paperwidth/3)}
% 1.2cm is more or less half the width of the duck
\begin{scope}[xshift=\the\tmp@l-1.2cm, yshift=0.6*\the\paperheight]
\duck[body=ducksazul, head=ducksamarillo, water=cyan];
\end{scope}
\node at (\the\tmp@l, 0.4cm) {\usebox{\horducks}};
\pgfmathsetlength{\tmp@l}{\paperwidth/3}
\pgfmathsetlength{\tmp@w}{0.5666*\the\paperwidth+\the\left@shift-2cm)}
\node [anchor=south east, opacity=0.1] at (0.9*\the\paperwidth, -5pt) {\usebox{\bigduck}};
\pgfmathsetlength{\tmp@l}{\paperwidth/3-\left@shift+0.5cm}
\node [box, font=\large] at(\the\tmp@l,0.9*\the\paperheight) {\ducks@toptitlepage};
\node [box, font=\Large] at(\the\tmp@l,0.7*\the\paperheight) {\textbf{\inserttitle}\\ \insertsubtitle};
\node [box, font=\large, color=white] at(\the\tmp@l,0.28*\the\paperheight) {\insertauthor};
\end{tikzpicture}
}
%
% We have two lines in the footline. Not convinced, but alas ---
%
\setbeamertemplate{footline}{%
\begin{tikzpicture}[
box/.style={%draw,
anchor=south west,
text width=\the\tmp@w,
align=left,
},
]
\useasboundingbox (0,0) rectangle (\the\paperwidth, 1cm);
% \fill[color=cyan!30] (0,0) rectangle (\the\paperwidth, 1cm); % for debug
\pgfmathsetlength{\tmp@w}{(\the\paperwidth-\the\left@shift-4cm)/2} % 2 cm for the number, 1+1 for separation
\node [box, color=ducksgris, font=\bfseries](lb) at(\the\left@shift, 0) {\ducks@leftbelow};
\node [box, color=black, font=\bfseries](lt) at (lb.north west) {\ducks@leftabove};
\node [box, color=ducksgris, font=\bfseries](rb) at(\the\left@shift+1cm+\the\tmp@w, 0) {\ducks@rightbelow};
\node [box, color=black, font=\bfseries] at (rb.north west) {\ducks@rightabove};
\node [anchor=south east, color=ducksgris, font=\large] at (\the\paperwidth, 0) {\strut\insertframenumber/\inserttotalframenumber};
\draw (lt.north west) ++(0,2pt) -- ++(\the\tmp@w/2,0);
\end{tikzpicture}
}
%
% Misc things
%
\setbeamertemplate{sidebar right}{}% or get rid of navigation entries there somehow
\addtobeamertemplate{footnote}{\vspace{0.5ex}}{}
\renewcommand*{\footnoterule}{\vspace{0.5ex}\hrule width 2in\relax}
\setbeamertemplate{navigation symbols}{}
%
% Create a section with a "special" slide.
%
\newcommand{\SlideSection}[2][]{%
\ifthenelse{\isempty{#1}}{%
\section{#2}}{%
\section[#1]{#2}}%
%
{
\setbeamertemplate{footline}{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth, 1cm);
\fill[color=ducksazul] (0,0) rectangle (0.7*\the\paperwidth, 1cm);
\node [anchor=south east] at (\the\paperwidth, 0cm) {\usebox{\horducks}};
\end{tikzpicture}
}
\begin{frame}
\frametitle{}
\begin{tikzpicture}[
]
\path [use as bounding box] (0,0) rectangle (0.9*\the\paperwidth-\the\left@shift, 0.8*\the\paperheight);
\node [anchor=north west, minimum size=2cm, fill=ducksgris!30, font=\Huge\bfseries]
(nb) at (0, 0.6*\the\paperheight) {\color{white}\thesection};
\node [anchor=north west, text width=0.7*\the\paperwidth, font=\Large, align=center]
(tb) at (0, 0.3*\the\paperheight) {#2};
\begin{scope}[thin, color=ducksazul]
\draw (nb.north west) ++(7pt,2pt) -- ++(-14pt, 0);
\draw (nb.north west) ++(-2pt,-3pt) -- ++(0, 8pt);
\draw (nb.south west) ++(7pt,-2pt) -- ++(-14pt, 0);
\draw (nb.south west) ++(-2pt,-5pt) -- ++(0, 16pt);
\draw (nb.north east) ++(7pt,2pt) -- ++(-14pt, 0);
\draw (nb.north east) ++(2pt,-10pt) -- ++(0, 16pt);
\draw (tb.south west) ++(7pt,-2pt) -- ++(-14pt, 0);
\draw (tb.south west) ++(-2pt,-5pt) -- ++(0, 16pt);
\draw (tb.north east) ++(7pt,2pt) -- ++(-14pt, 0);
\draw (tb.north east) ++(2pt,-10pt) -- ++(0, 16pt);
\end{scope}
\end{tikzpicture}
\end{frame}
}
}
%
% end
%

The following code shows you how to use the style to obtain this:

 

% vim: set spell spelllang=en :
 %%%
 \PassOptionsToPackage{table}{xcolor}
 \PassOptionsToPackage{unicode}{hyperref}
 \documentclass[12pt,
     % ,handout %% "handout" for one page per slide
     ,aspectratio=169 %%
     % ,aspectratio=1610 %%
     % ,aspectratio=32 %%
 ]{beamer}
 %%%
 \usepackage[T1]{fontenc}
 \usepackage[utf8]{inputenc}
 \usepackage{lmodern} % basic font
 %
 \usetheme{duck}
 %
 %% presentation data starts here
 %%
 %% Title page
 \title{Testing duck style}
 \subtitle{Subtitle}
 \toptitlepage{duck, test slide}
 \author[RGtti]{Romano Giannetti}
 \date{\today}
 %% Definitions for the footer
 \leftabove{Left Above}
 \leftbelow{Left Below}
 \rightabove{Right Above}
 \rightbelow{Right Below}
 %% For example; you can find more \insert… at
 %% http://www.cpt.univ-mrs.fr/~masson/latex/Beamer-appearance-cheat-sheet.pdf
 \leftabove{\insertshorttitle}
 \leftbelow{\insertshortauthor}
 \rightabove{\insertsectionhead}
 \rightbelow{\today}
 % you can change bg's image transparency here
 \bgduckopacity{0.10}% (background semitransparent lion) default=0.2
 \begin{document}

Enjoy it!

You can download the files clicking here (can’t find how to add the nice link…)

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.