Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I just want to add a background only in the beamer title page. I can add it in the .tex as follows:

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

But I don't want the above command in the .tex, but in the .sty files. Thanks for pointing me out how I can add the above command in the .sty files.

Please find the .sty and .tex files below (all of them are quite simple).


main.sty

\mode<presentation>

\DeclareOptionBeamer{titlepage}{\PassOptionsToPackage{titlepage=#1}{beamertheme-Inner}}
\ProcessOptionsBeamer

\usetheme{Inner}
\usetheme{Outer}

\setbeamertemplate{navigation symbols}{}

\mode
<all>

inner.sty

\mode<presentation>


\DeclareOptionBeamer{titlepage}{\def\beamer@titlepage{#1}}

\defbeamertemplate*{titlepage}
{
  \begin{center}
    \usebeamerfont{title}\inserttitle
    \ifx\insertsubtitle\@empty
    \else
      \vskip2ex
      \usebeamerfont{subtitle}\insertsubtitle
    \fi
    \ifx\insertauthor\@empty
    \else
      \vskip2ex
      \usebeamerfont{author}\insertauthor
    \fi
    \ifx\insertdate\@empty
    \else
      \vskip2ex
      \usebeamerfont{date}\insertdate%
    \fi
  \end{center}
  \vfill
}

.tex file

\usetheme{Afnic}

\title{An example theme for \LaTeX{} Beamer}
\author{Sandoche}
\date{February 29, 2012}

\begin{document}

\begin{frame}[plain]
  \maketitle
\end{frame}

\AtBeginSection[]
{
   \begin{frame}
       \frametitle{Outline}
       \tableofcontents[currentsection]
   \end{frame}
}
share|improve this question
    
This is the first time i am hearing about tikz :-). Which tikz code are you referring to ? –  sandoche Mar 1 '12 at 13:02
    
Yes it didn't work. –  sandoche Mar 1 '12 at 13:16
    
I changed the title a little … –  Tobi Mar 5 '12 at 14:19

2 Answers 2

up vote 15 down vote accepted

You could check for the frame number:

\setbeamertemplate{background canvas}{%
    \ifnum\c@framenumber=1%
        % On title page
    \fi%
}

You may extend this to set thing to all frames except the title:

\setbeamertemplate{background canvas}{%
    \ifnum\c@framenumber=1%
        % On title page
    \else%
            % Other frames background
    \fi%
}

Extended version

As requested a version that also checks for the last frame. We use etoolbox to enable nested if statements.

\documentclass{beamer}

\usepackage{etoolbox}

\makeatletter

\setbeamertemplate{background canvas}{%
   \ifnumequal{\c@framenumber}{1}{%
      % First frame
      \color{red!50}\rule{\paperwidth}{\paperheight}
   }{%
      \ifnumequal{\c@framenumber}{\inserttotalframenumber}{
         % Last frame
         \color{orange!50}\rule{\paperwidth}{\paperheight}
      }{%
         % Other frames
         \color{green!50}\rule{\paperwidth}{\paperheight}
      }%
   }%
}

\makeatother

\begin{document}
\frame{1}

\frame{2}

\frame{3}

\frame{4}
\end{document}

different backgrounds

\c@framenumber is the counter of the current frame and \inserttotalframenumber holds the number of the last frame. Certanly one can omit the Other frames part

share|improve this answer
    
Simply great you are. I have spent nearly one and a half day on this. Just not to disturb you too much, can i do the similar for the last page in the case where the frame number is not known. Thanks again. –  sandoche Mar 1 '12 at 16:01
    
@sandoche: I’ll have a look at that soon :-) –  Tobi Mar 1 '12 at 18:16
    
@sandoche: I added an extended version … –  Tobi Mar 1 '12 at 22:22
    
Sorry for the delay as i was in holidays. Impeccable as the French say. What should i do to give you full marks. –  sandoche Mar 5 '12 at 8:27
    
@sandoche: I’m not sure what you mean with “full mark” but if my answer answers your question u may upvote it and click the gray check mark to accept my answer. –  Tobi Mar 5 '12 at 12:15

The solution of Tobi has some significant disadvantages. It only works when the titlepage is actually the first frame and also produces a problem when not using the titlepage. A somewhat better solution is using the \AddToShipoutPictureFG* command of eso-pic inside the \setbeamertemplate{title page} command. So the code for the askers inner.sty would be:

\setbeamertemplate{title page}
{
  \AddToShipoutPictureFG*{\includegraphics[width=\paperwidth,height=\paperheight]{img/bg-first.pdf}}
  \begin{center}
    \usebeamerfont{title}\inserttitle
    \ifx\insertsubtitle\@empty
    \else
      \vskip2ex
      \usebeamerfont{subtitle}\insertsubtitle
    \fi
    \ifx\insertauthor\@empty
    \else
      \vskip2ex
      \usebeamerfont{author}\insertauthor
    \fi
    \ifx\insertdate\@empty
    \else
      \vskip2ex
      \usebeamerfont{date}\insertdate%
    \fi
  \end{center}
  \vfill
}
share|improve this answer
    
Hi, I have an issue using \AddToShipoutPictureFG if I display notes on a second screen. The exact command is: \setbeameroption{show notes on second screen=left}. The background is on the note and not on the titlepage now! –  asn Jan 30 at 15:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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