Beamer: How to set background color only on title page in theme

backgroundsbeamercolorthemes

I'm developing a Beamer theme and I want to make the background color of the title page one color and all the other slides to have a different color.

I've found that I can change the background color for a slide using:

\setbeamercolor{background canvas}{bg=violet}

I want to do this in the beamer theme style file, not in the latex document and I couldn't figure out how to do that.


I know I can change the background color on slide 1 like this:

\setbeamertemplate{background}{%
    \ifnum\c@framenumber=1%
        \begin{tikzpicture}[background rectangle/.style={fill=blue}, show background rectangle]
            \hspace*{20em}
            \node[opacity=0.45, scale=5.6]{\includegraphics{background}};
        \end{tikzpicture}
    \else%
    \begin{tikzpicture}[background rectangle/.style={fill=white}, show background rectangle]
            \hspace*{20em}
            \node[opacity=0.09, scale=5.6]{\includegraphics{background}};
        \end{tikzpicture}
    \fi%

This works if the title slide is the first slide—almost always the case. It does not work if putting multiple title slides in the same file, which I do on occasion.


Here is what I'm trying to accomplish. In this example, I'm using the excellent Metropolis theme. This example shows that I can have two different title slides in the same presentation. It does not show that there is a different background color in the title slide. Of course, I want to implement this in my own theme. (I'm sorry that I can't share all of my style file.)

\documentclass{beamer}

\usetheme{metropolis}

\begin{document}
\title{First Title}
\begin{frame}
  \maketitle
\end{frame}

\begin{frame}{Some title}
  Some content here
\end{frame}

\title{Second Title}
\begin{frame}
  \maketitle
\end{frame}

\end{document}

MWE1
MWE2
MWE3

Best Answer

You can add a tikzpicture to the title page template that draws the background directly use the coordinates of the current page:

Sample output

beamerthememytheme.sty

\usetheme{metropolis}

\usetikzlibrary{backgrounds}

\addtobeamertemplate{title page}{%
\begin{tikzpicture}[remember picture, overlay]
  \draw[fill=violet!20!white] (current page.south west) rectangle
  (current page.north east);
\end{tikzpicture}%
}{}

main file

\documentclass{beamer}

\usetheme{mytheme}

\begin{document}
\title{First Title}
\begin{frame}
  \maketitle
\end{frame}

\begin{frame}{Some title}
  Some content here
\end{frame}

\title{Second Title}
\begin{frame}
  \maketitle
\end{frame}

\end{document}