5

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?
    – Werner
    Oct 25 '21 at 16:40
  • 1
    @Werner I've uploaded an example of using two title slides in the same presentation. I hope this helps!
    – jlconlin
    Oct 25 '21 at 16:57
2
+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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.