0

I am working on replicating a PowerPoint theme used by institute in beamer. This theme has different background images for the main content, title, and section slides along with text that appears in the headers and footers. I would like to incorporate automatic switching of the background image based on the frame's current theme. I know the background can be changed by enclosing the frame inside a group, but I'd prefer to have the theme handle the image. I know I can also explicitly set the image in the proper theme; however, that blocks the view of the globally set header text. Based on this issue, it looks like this is tied directly to they layering (I essentially want the reverse of the reported issue)beamer has to do to get the job done. That seems to imply that elevating the text above a locally set background image is not possible. I also know it's possible to use \AtBeginSection and friends to create the grouping, but I'd prefer to not have to always have a title/part/section slide.

My question is: How can I change the background image based on the current beamer frame's theme? Alternatively, how could I bring the header above the locally set background image in the title theme?

As a minimum working example:

\documentclass{beamer}

\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{positioning}

\setbeamercolor{page number in head/foot}{fg=red}

\setbeamertemplate{title page}{%
    \begin{tikzpicture}[remember picture, overlay]
        \node [anchor=center] at (current page.center) {%
            \includegraphics[width=\paperwidth,
                             height=\paperheight]{example-image-a}
        };
        % The following does not respect the font selection in the
        % template
        %\node [below=0pt of current page.north,
               %text width=\paperwidth] {
            %\usebeamertemplate{headline}
        %};
    \end{tikzpicture}
}

\setbeamertemplate{headline}{%
    \vspace{0.5em}
    \usebeamercolor[fg]{page number in head/foot}
    \hspace*{\fill}
    TEXT
    \hspace*{\fill}
}

\setbeamertemplate{sidebar right}{}
\setbeamertemplate{footline}{%
    \usebeamercolor[fg]{page number in head/foot}
    \usebeamerfont{page number in head/foot}
    \hspace*{\fill}
    TEXT
    \hspace*{\fill}
    \vspace{0.5em}
}

\setbeamertemplate{background}{%
    \includegraphics[width=\paperwidth,
                     height=\paperheight]{example-image}
}

\begin{document}
\begin{frame}
    \titlepage
\end{frame}

\begin{frame}{Example}
    Stuff
\end{frame}

\end{document}
0

A possible solution: put different background images in the headline templates.

\documentclass{beamer}

\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{positioning}

\setbeamertemplate{title page}{%
  \Huge Huge Title Huge Title Huge Title Huge Title Huge Title
}

\defbeamertemplate*{headline}{zero}{%
    \begin{tikzpicture}[remember picture, overlay,opacity=0.3]
        \node [anchor=center] at (current page.center) {%
            \includegraphics[width=\paperwidth,
                             height=\paperheight]{example-image}
        };
    \end{tikzpicture}
    \vspace{0.5em}
    \usebeamercolor[fg]{page number in head/foot}
    \hspace*{\fill}
    \Large Title Head
    \hspace*{\fill}
}

\defbeamertemplate{headline}{first}{%
    \begin{tikzpicture}[remember picture, overlay,opacity=0.3]
        \node [anchor=center] at (current page.center) {%
            \includegraphics[width=\paperwidth,
                             height=\paperheight]{example-image-a}
        };
    \end{tikzpicture}
    \vspace{0.5em}
    \usebeamercolor[fg]{page number in head/foot}
    \hspace*{\fill}
    \Large Section Head
    \hspace*{\fill}
}

\defbeamertemplate{headline}{second}{%
    \begin{tikzpicture}[remember picture, overlay,opacity=0.3]
        \node [anchor=center] at (current page.center) {%
            \includegraphics[width=\paperwidth,
                             height=\paperheight]{example-image-b}
        };
    \end{tikzpicture}
    \vspace{0.5em}
    \usebeamercolor[fg]{page number in head/foot}
    \hspace*{\fill}
    \Large Normal Head
    \hspace*{\fill}
}

\defbeamertemplate*{footline}{zero}{
    \usebeamercolor[fg]{page number in head/foot}
    \usebeamerfont{page number in head/foot}
    \hspace*{\fill}
    \Large Title Foot
    \hspace*{\fill}
    \vspace{1.5em}
}

\defbeamertemplate{footline}{first}{
    \usebeamercolor[fg]{page number in head/foot}
    \usebeamerfont{page number in head/foot}
    \hspace*{\fill}
    \Large Section Foot
    \hspace*{\fill}
    \vspace{1em}
}

\defbeamertemplate{footline}{second}{
    \usebeamercolor[fg]{page number in head/foot}
    \usebeamerfont{page number in head/foot}
    \hspace*{\fill}
    \Large Normal Foot
    \hspace*{\fill}
    \vspace{0.5em}
}

\AtBeginSection{%
  {
    \setbeamertemplate{headline}[first]
    \setbeamertemplate{footline}[first]
    \begin{frame}\sectionpage\end{frame} 
  }
  \setbeamertemplate{headline}[second]
  \setbeamertemplate{footline}[second]
}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\section{First Section}

\begin{frame}{Example One}
 Stuff Stuff Stuff Stuff Stuff Stuff Stuff Stuff
\end{frame}

\begin{frame}{Example Two}
 Stuff Stuff Stuff Stuff Stuff Stuff Stuff Stuff
\end{frame}

\end{document}

enter image description here

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.