# How to make the end slide use the same background as title page, while the normal slide use different background?

This post relates to another post How to make company presentation slides template including logos, title slide, normal slide, and ending slide?. Here I ask more detailed question.

I am making a template for presentation slides using beamer class.

I followed the post Design a custom Beamer theme from scratch and made the following codes in the file called beamerinnerthememytheme.sty.

\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=mygray] (0,2) rectangle (\the\paperwidth,\the\paperheight);
\ifnum\thepage>1\relax%
\fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fi
\end{tikzpicture}
}


However, the code above ifnum\thepage>1\relax% let the background only visible on the first page (title page). I want the same background for the ending slide also. Do you know how to do that?

So the logic would be something like: if the page number is large than 1 or less than the end, then \relax.

Note that this is meant to be a template, so the number of slides can be different for each case. And people can use

\begin{enumerate}
\item<2-> blablabla
\item<3-> blblbl
\item<1-> blbblblbbl
number not in the first $p$ numbers.
\end{enumerate}


This enumerate slides slides have the same page number in the resulting pdf file. So, \inserttotalframenumber would not work.

Do you know how to do this? Or any other suggestions without using ifnum ... are also welcomed.

Hard coded values like first or last page are IHMO a bad idea. What happens if the titlepage is not the first page of the presentation? Or if a presentation does not have an end slide?

I suggest something like this instead:

\documentclass{beamer}
\usepackage{tikz}

\defbeamertemplate{background}{special frames}{%
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=gray] (0,2) rectangle (\the\paperwidth,\the\paperheight);
\end{tikzpicture}
}

\setbeamertemplate{background}{
\begin{tikzpicture}
\fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
\end{tikzpicture}
}

\newcommand{\insertendpage}{%
\setbeamertemplate{background}[special frames]
\begin{frame}
bla bla
\end{frame}
}

\setbeamertemplate{title page}{%
\setbeamertemplate{background}[special frames]
\begin{frame}
text text
\end{frame}
}

\begin{document}

\titlepage

\begin{frame}
Slide 2
\end{frame}

\insertendpage

\end{document}