5

I would like to change my background canvas according to whether my frame has a title. This is the form I'm using (etoolbox):

\setbeamertemplate{background canvas}{
   \ifnumequal{\c@framenumber}{1}{%
      % First frame
   }{%
      \ifnumequal{\c@framenumber}{\inserttotalframenumber}{
         % Last frame
      }{%
         %\if{\frametitle}{empty}{
         % Empty frames
        }{%  
           % Other frames
          }%
   }%
}

Thanks in advance.

  • I've not tested but, is \ifstrempty{\beamer@frametitle}{<true>}{<false>} what you are looking for? – Ignasi Feb 7 '14 at 18:21
  • That didn't work, I'm just getting the "false" background. code is now like this: \setbeamertemplate{background canvas}{ \ifstrempty{beamer@frametitle}{ % Empty frames }{% % Other frames }% } Don't really know why... – Joe H. Feb 8 '14 at 8:01
3

You can use a conditional \ifx to test for \insertframetitle to see if it's empty and act accordingly, A simple example adding an image with a "B" in frames with title, and an image with an "A" for frames with titles:

\documentclass{beamer}
\usepackage{tikz}

\makeatletter
\setbeamertemplate{background canvas}{%
\ifx\insertframetitle\@empty
  \tikz[remember picture,overlay]
    \node[opacity=0.2] at (current page.center) 
      {\includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}};
\else
  \tikz[remember picture,overlay]
    \node[opacity=0.2] at (current page.center)   
      {\includegraphics[width=\paperwidth,height=\paperheight]{example-image-b}};
\fi%
}
\makeatother

\begin{document}

\begin{frame}
\frametitle{A frame with a title}
test
\end{frame}

\begin{frame}
test
\end{frame}

\end{document}

enter image description here

  • works like charm, even in my nested etoolbox statement.Thanks a lot. – Joe H. Feb 8 '14 at 8:12

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.