# Beamer: Blackboard theme and overlays

I am currently preparing my beamer presentation for my PhD defense.

I took the example at the url blackboardTheme to get a black board style presentation.

This template includes a short script which uses a random-generator to randomly scatter dust-trails on the black background to mimic chalk traces (see MWE below).

The thing is that parallel to that, I am also using overlays to uncover my slide layout by layout. The script is executed each time I am using a layout command which slows down the compilation quite substantially. I am not so familiar with control statements in latex, so here is my question:

How can-I modify this script for the background to be refreshed only when the slide is over, and not after each layout command?

Remarks:

1) I am using the Augie font, but I didn't included it in the MWE so that it can be compiled more easily

2) In case, it should make a difference I am also using the \begin{textblock*} \end{textblock*} environment from the textpos package to position text on the slide.

Here is my MWE:

\documentclass[10pt,mathserif]{beamer}

\usepackage[francais,english]{babel}
\usepackage[utf8] {inputenc} %for ISOlatin1 (8859-1) sources
\usepackage[T1] {fontenc}      %for polices DC 8bits

%%%Fancy fonts
%\usepackage{emerald}
%\usepackage{eulervm}
%%%

%%Extra packages
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usepackage[absolute,overlay]{textpos}

%set text colors for different objects
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{example text}{fg=white}

%%Black background
\setbeamercolor{background canvas}{bg=black}

%%%%%%%%%%%%%%%%%%%%%%
%%%%%Script: Random Dust Trails%%%%%%%%%%%%%%%
\pgfmathsetseed{\number\pdfrandomseed} % seed for random generator
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight);
\foreach \i in {1,...,30} {
\pgfmathsetmacro{\x}{random(0,10000)/5000-1}%
\pgfmathsetmacro{\y}{random(0,10000)/10000-0.1}%
\pgfmathsetmacro{\r}{random(0,10000)/1000-5}%
\rotatebox{\r}{
\pgftext[at=\pgfpoint{\x\paperwidth}{\y\paperheight}, left, base]{\includegraphics[width=\textwidth]{paintstroke.png}}
}
};
\end{tikzpicture}
}
%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{frame}

\begin{itemize}
\item<1-> bla slide 1
\item<2-> blu slide 1
\item<3-> blub slide 1
\end{itemize}

\end{frame}

%%I want the background to be refreshed with the Dust Trails script only at the end of the frame

\begin{frame}

\begin{itemize}
\item<1-> bla slide 2
\item<2-> blu slide 2
\item<3-> blub slide 2
\end{itemize}

\end{frame}

\end{document}


This is my first post, so please be kind if I did something illegal on the formatting of the message ;-).

Yannick

• I think Beamer already load package amsmath and amsfonts. I am not sure but you could check its manual :) – Say OL Sep 15 '15 at 23:01

To prevent the random generation at each overlay, here is a solution which stores the picture in a savebox and reuses it. With the command \background the dust trails can be refreshed.

\documentclass[10pt,mathserif]{beamer}

\usepackage[francais,english]{babel}
\usepackage[utf8] {inputenc} %for ISOlatin1 (8859-1) sources
\usepackage[T1] {fontenc}      %for polices DC 8bits

%%%Fancy fonts
%\usepackage{emerald}
%\usepackage{eulervm}
%%%

%%Extra packages
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usepackage[absolute,overlay]{textpos}
\usepackage{etoolbox}

%set text colors for different objects
\setbeamercolor{frametitle}{fg=white}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{example text}{fg=white}

%%Black background
\setbeamercolor{background canvas}{bg=black}

%%%%%%%%%%%%%%%%%%%%%%
%%%%%Script: Random Dust Trails%%%%%%%%%%%%%%%
\pgfmathsetseed{\number\pdfrandomseed} % seed for random generator
\setbeamertemplate{background}{
\usebox{\mypicture}
}
%%%%%%%%%%%%%%%%%%%%%%

\BeforeBeginEnvironment{frame}{%
\begin{lrbox}{\mypicture}
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle (\the\paperwidth, \the\paperheight);
\foreach \i in {1,...,30} {
\pgfmathsetmacro{\x}{random(0,10000)/5000-1}%
\pgfmathsetmacro{\y}{random(0,10000)/10000-0.1}%
\pgfmathsetmacro{\r}{random(0,10000)/1000-5}%
\rotatebox{\r}{
\pgftext[at=\pgfpoint{\x\paperwidth}{\y\paperheight}, left, base]{\includegraphics[width=\textwidth]{paintstroke.png}}
}
};
\end{tikzpicture}
\end{lrbox}
}

\begin{document}

\newsavebox{\mypicture}
\begin{frame}

\begin{itemize}
\item<1-> bla slide 1
\item<2-> blu slide 1
\item<3-> blub slide 1
\end{itemize}

\end{frame}

\begin{frame}

\begin{itemize}
\item<1-> bla slide 2
\item<2-> blu slide 2
\item<3-> blub slide 2
\end{itemize}

\end{frame}

\end{document}

• Nice solution. With etoolbox package help, you can add \BeforeBeginEnvironment{frame}{\background} in your preamble and avoid writing \background after every frame. – Ignasi Sep 15 '15 at 7:06
• Ok, thank you very much for both your answers, that was exactly what I was looking for. Out of curiosity, is there a possibility to implement an instruction of the type 'If[Nextslide == True] than \background' in latex? – Yannick Sep 15 '15 at 22:07
• @Yannick That is in principle what the comment of Ignasi does. I will edit my answer accordingly – user36296 Sep 15 '15 at 22:42
• @Ignasi Good Idea! I edited the answer – user36296 Sep 15 '15 at 22:42
• Ok thanks! I have marked the question as answered. – Yannick Sep 16 '15 at 14:21