# Different background for section page in Beamer

On this picture you can see a titlepage, a section page and a content page done in Powerpoint:

How to modify this code so that the section page has the background shown on the image? I can do the text positioning by myself later on.

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz, datetime, textpos}
\yyyymmdddate \renewcommand{\dateseparator}{.}

\definecolor{MedianBrown}{RGB}{119,95,85}
\definecolor{MedianLightBrown}{RGB}{235,221,195}
\definecolor{MedianLightBlue}{RGB}{148,182,210}
\definecolor{MedianOrange}{RGB}{221,128,71}
\setbeamercolor*{title}{fg=MedianLightBrown}
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{item}{fg=MedianOrange}
\setbeamercolor*{frametitle}{fg=MedianBrown}

\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\ifnum\thepage>1\relax% Not the title page
\fill[color=MedianOrange] (0,8) rectangle(0.8,8.3);
\fill[color=MedianLightBlue] (0.9,8) rectangle(\the\paperwidth, 8.3);
\else% Title page
\fill[color=MedianBrown] (0,1.5) rectangle (\the\paperwidth,\the\paperheight);
\fill[color=MedianOrange] (0,0.1) rectangle(3.45,1.4);
\fill[color=MedianLightBlue] (3.55,0.1) rectangle(\the\paperwidth,1.4);
\fi
\end{tikzpicture}
}

\setbeamertemplate{title page}
{
\begin{textblock*}{12cm}(3cm,2.8cm)
\usebeamerfont{title}\usebeamercolor{title}\inserttitle%
\end{beamercolorbox}%
\end{textblock*}
\begin{textblock*}{12cm}(-0.5cm,4.9cm)
\begin{beamercolorbox}{date}
\usebeamerfont{date}\insertdate%
\end{beamercolorbox}
\end{textblock*}
\begin{textblock*}{9cm}(3cm,4.9cm)
\begin{beamercolorbox}{author}
\usebeamerfont{author}\insertauthor%
\end{beamercolorbox}
\end{textblock*}
}

\setbeamertemplate{frametitle}
{
\vskip0.3cm
\begin{beamercolorbox}{frametitle}
\insertframetitle
\end{beamercolorbox}
}
\setbeamertemplate{items}[square]
\setbeamertemplate{sections/subsections in toc}[square]

\author{Author Name}
\title{Quite A Long Title For A Simple Beamer Presentation}
\date{\today}

\begin{document}
\frame{\maketitle}
\section{Introduction}
\frame{\sectionpage}
\begin{itemize}
\item Some stuff
\item And some other stuff
\end{itemize}
\end{frame}
\end{document}

-
To clarify, You want the \sectionpage background color to be MedianBrown, right? –  dcmst Nov 25 '13 at 11:41
@dcmst No, I want the section page to have the background as shown in the second slide of the PowerPoint example at the top. Essentially similar to the normal background but the blue rectangle height is bigger so that the section title fits on it, and the orange rectangle to the left has the same height. –  marczellm Nov 25 '13 at 11:47
@dcmst The slight brownish background of the sectionpage in Powerpoint are actually thin stripes, but that can be ignored. –  marczellm Nov 25 '13 at 11:48
Is the question about installing a different background on certain conditions or about how to draw the graphics with tikz? –  Bordaigorl Nov 25 '13 at 12:00
@Bordaigorl Installing a different background on certain conditions. –  marczellm Nov 25 '13 at 12:04

I'll add my answer too, the approach is the same of Bordaigorl but with less code involved.

The idea is to create another \setbeamertemplate{background} and embed it into a custom command to be used instead of \frame{\sectionpage}

The custom command will redefine the background and then the section page template. Just as an example I used a tikzpicture to reposition the section head.

This is the custom command:

\newcommand{\mysectionpage}{
\begingroup
\setbeamertemplate{background}{
\begin{tikzpicture}                                         %edit this tikzpicture to customize the size and colors of the background rectangles
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=MedianOrange] (0,7) rectangle(0.8,8);
\fill[color=MedianLightBlue] (0.9,7) rectangle(\the\paperwidth, 8);
\end{tikzpicture}
}
\setbeamercolor{section page}{fg=white}
\setbeamertemplate{section page}{
\begin{tikzpicture}                                             %edit this tikzpicture to customize the appearance of the section heading
\end{tikzpicture}
}
\frame{\sectionpage}
\endgroup
}


The rest of your preamble code stays untouched. The body of the document will look like this:

\begin{document}
\frame{\maketitle}
\section{Introduction}
\mysectionpage                                 %new code
\begin{itemize}
\item Some stuff
\item And some other stuff
\end{itemize}
\end{frame}
\end{document}


The result is:

-
In my answer I was suggesting the commands producing the titleframe because it leads to a more flexible approach than producing different backgrounds by testing the page number: what if you want another title page later on? It is also more uniform since both section and title pages get generated in the same way. Do you know of any hook in frame to install the backgrounds from within the frame? –  Bordaigorl Nov 25 '13 at 17:37
@Bordaigorl Why your pres. should have more than one title? My assumption was: 1 title -> 1 pres. However if you really want to you can replicate my approach for the frame with the title, it's just a copy-paste exercise. Then you will have also uniformity. Anyway, IMO the perfect solution would be to extend the OP approach with another if. Smthg like if this is a sectionpage then install this background. But I don't know how you could test for a sectionpage, I'll research it when I have time (maybe I'll post a question too) –  dcmst Nov 25 '13 at 17:50
I mention flags in my answer for that reason: you need to set them before starting the frame if you want the background template to react accordingly. If you stick with the \sectiontitle macro you can do that very easily. I can write another answer if you are interested –  Bordaigorl Nov 25 '13 at 17:58
@Bordaigorl sure I am, please do, thanks. –  dcmst Nov 25 '13 at 18:19
here it is. Let me know if that's what you were looking for –  Bordaigorl Nov 25 '13 at 19:10

Another option following the same pattern as the MWE which uses conditionals to define the background once and forall. I do not like this approach as it is not very modular but since @dcmst asked here's a solution with conditionals.

First let's introduce a new conditional for section pages and set it to false

\newif\ifinsectionframe
\insectionframefalse


Now we can change the background template as follows

\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\ifnum\thepage>1\relax% Not the title page
\ifinsectionframe%
\node {Some background}; %% INSERT YOUR GRAPHICS HERE
\else%
\fill[color=MedianOrange] (0,8) rectangle(0.8,8.3);
\fill[color=MedianLightBlue] (0.9,8) rectangle(\the\paperwidth, 8.3);
\fi%
\else% Title page
\fill[color=MedianBrown] (0,1.5) rectangle (\the\paperwidth,\the\paperheight);
\fill[color=MedianOrange] (0,0.1) rectangle(3.45,1.4);
\fill[color=MedianLightBlue] (3.55,0.1) rectangle(\the\paperwidth,1.4);
\fi
\end{tikzpicture}
}


Then we can create a \sectionframe macro that sets the corresponding flag before creating a frame with the section page:

\newcommand{\sectionframe}{
\insectionframetrue
\frame{\sectionpage}
\insectionframefalse
}


Then if you use \sectionframe instead of \frame{\sectionpage} you have the desired effect.

A note on the conditional to detect the title page: I would recommend creating a new if \ifintitleframe instead of checking the page number; apart from being more semantically sound it is also more flexible because you can now have title frames on an arbitrary page (even more than one) instead than forcing it to be on the first page.

-
that's it, thanks –  dcmst Nov 25 '13 at 19:22

The problem is that the section page template gets "called" within a frame but the background template can only be changed before starting the frame. Also, setting flags patching \sectionpage probably wont work because it would set them after the background is typeset.

So, the simplest solution is to define a macro to create the section frame (instead of page) so you can inject the background-changing code before starting the frame.

First let's introduce few macros to change the background:

\newcommand{\setslidebg}{
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=MedianOrange] (0,8) rectangle(0.8,8.3);
\fill[color=MedianLightBlue] (0.9,8) rectangle(\the\paperwidth, 8.3);
\end{tikzpicture}
}
}
\newcommand{\setsecbg}{
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\node {Something else};
\end{tikzpicture}
}
}
\newcommand{\settitlebg}{
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=MedianBrown] (0,1.5) rectangle (\the\paperwidth,\the\paperheight);
\fill[color=MedianOrange] (0,0.1) rectangle(3.45,1.4);
\fill[color=MedianLightBlue] (3.55,0.1) rectangle(\the\paperwidth,1.4);
\end{tikzpicture}
}
}

\setslidebg


where you can replace the tikzcode in \setsecbg to produce the desired graphics.

Then you can simply create the macros \titleframe and \sectionframe as follows:

\newcommand{\titleframe}{
\settitlebg
\frame{\maketitle}
\setslidebg
}

\newcommand{\sectionframe}{
\setsecbg
\frame{\sectionpage}
\setslidebg
}


so now you can just write \titleframe instead of \frame{\maketitle} and have your backgrounds set accordingly.

-