# My last frame should be n-1 slide

I have set in my .sty file as follows (to have a predefined background in my last slide):

\setbeamertemplate{background canvas}{
% Last frame
\includegraphics[width=\paperwidth,height=\paperheight]{img/bg-last.pdf}
}
}


The issue is the last frame in the .tex file overlaps on the above background. I want my last frame in the .tex file to be n-1 slide.

-
Maybe I didn't understand you correctly, but why can't you just add another (empty) frame (\frame{}) at the end of your presentation? – diabonas Mar 5 '12 at 16:51
Yes, thats an idea. But it's not so clean. – sandoche Mar 6 '12 at 7:45
BTW: The given code doesn't work out of the box: You need to load etoolbox, and \ifnumequal has four arguments, so a {} is missing after the closing brace in l. 5. The full working code can be found in the question How to add background only to title frame and an other only to the last frame?. – diabonas Mar 6 '12 at 11:28

I still don't fully understand why this should be done automatically, but you can simply add the final frame with \AtEndDocument. Like this, you don't have to check for the last frame with \ifnumequal{\c@framenumber}{\inserttotalframenumber}{...}{...} either, instead you can use \setbeamertemplate{background canvas}{...} in a group to define a custom background for the last (otherwise empty) slide.

### Example code:

\documentclass{beamer}
\AtEndDocument{%
{%
\setbeamertemplate{background canvas}{%
\includegraphics[width=\paperwidth,height=\paperheight]{img/bg-last.pdf}%
}%
\frame{}%
}}
\begin{document}
\begin{frame}
Content
\end{frame}
\end{document}


To incorporate this into your .sty file, just use the \AtEndDocument call (ll. 2-8).

-
You got it right. This is what i wanted. – sandoche Mar 6 '12 at 13:04