# Beamer: define a backgroung color for the “part page” frames

I'm trying to make a .sty template, but I cannot figure out how to define a dedicated background canvas for the "part page" frames.

Here (How to add background only to title frame and an other only to the last frame?) is a solution for when it is possible to characterize the background depending on the frame number, but it cannot be applied in my situation.

So is there a way to test the "type" of frame? (like "title page", "part page", ...). If yes, it means I can do the same as the solution to sandoche's problem. If not, can anybody think of a workaround?

As far as I know, the background canvas is drawn before the actual contents of the frame are read. So in \frame{\partpage}, the background is drawn before beamer sees the \partpage and can realize that the frame is a part page.

If you want a \frame{\partpage} immediately after every \part{}, then you can simply hook into \AtBeginPart:

\documentclass{beamer}

\AtBeginPart{%
{%  start a group to keep the template change local
\setbeamertemplate{background canvas}{%
\color{red!50}\rule{\paperwidth}{\paperheight}%
}%
\frame{\partpage}%
}%  end group
}

\begin{document}
\part{The first part}
\frame{...}
\frame{...}
\part{The second part}
\frame{...}
\frame{...}
\end{document}


The solution offered by Caramdir does not allow to get a different background color for a part page when entering

\begin{frame}
\partpage
\end{frame}


Suppose that the background of a part page is given by the background color of the part-title (this can easily be adapted). Here is the trick. We first define a new page style which will be used for part-pages. This page style is then added in the part-page template.

For convenience, we also add a key so that the background color can easily be inserted using the bgcolor key.

Here is a complete example.

\documentclass{beamer}

\makeatletter
\setbeamercolor{background canvas}{use=part title,bg=part title.bg}%
\define@key{beamerframe}{bgcolor}[]{%
\ifx#1\@empty\else\setbeamercolor{part title}{bg=#1}\fi}
\makeatother

\setbeamercolor{part title}{bg=pink} % default color

\begin{document}

\part{First Part}

\begin{frame}
\partpage
\end{frame}

\part{Second Part}

\begin{frame}[bgcolor=yellow]
\partpage
\end{frame}

\end{document}


The first part-page has the default pink background color and the second one has a yellow background color. Another way to modify the background color in the previous example is via the \setbeamercolor:

\setbeamercolor{part title}{bg=yellow}
\begin{frame}
\partpage
\end{frame}

• @Caramdir: Here is a more flexible solution. – user94293 Jul 24 '16 at 5:22