7

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

2
  • 1
    Can you provide a basic minimal document, say one with a single title slide, and one with multiple slides (or non-first-slide) so the community can work with that information? Commented Oct 25, 2021 at 16:40
  • 1
    @Werner I've uploaded an example of using two title slides in the same presentation. I hope this helps! Commented Oct 25, 2021 at 16:57

3 Answers 3

4
+100

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}
0

\setbeamercolor{background canvas}{bg=violet} actually works, but I haven't found a way to use it in setbeamertemplate.

It can be used it document between frames to change their background as such:

\begin{document}

% Switch to custom background color for title frame
\setbeamercolor{background canvas}{bg=violet}

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

% Set back the background color for other frames.
\setbeamercolor{background canvas}{bg=white}

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

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

\end{document}
0

You can use the same trick as in https://topanswers.xyz/tex?q=1004#a1198 :

\documentclass{beamer}

\usetheme{moloch}% modern fork of the metropolis theme

\makeatletter
\def\ps@navigation@titlepage{%
  \setbeamercolor{background canvas}{bg=red}
  \@nameuse{ps@navigation}
}
\addtobeamertemplate{title page}{\thispagestyle{navigation@titlepage}}{}
\makeatother


\begin{document}

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

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

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

\end{document}

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.