[Tex/LaTex] usebackgroundtemplate after section

beamertemplates

I am attempting to insert a full-page figure into my slides, see the MWE below.

The first experience, that 'Title' and 'subtitle' appear
at their normal position. With the option 'plain' I expected to not appear.

The second one, that if I uncomment the 'section' command, I do have an extra slide, with section 'title' as frame title, on the top of the background figure, although the template is local. Do I misunderstand something?

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\begin{document}

%\section{sec}{title}
{
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{YourFigureHere}}%
\begin{frame}[plain]{Title}{Subtitle}
\end{frame}
}

\end{document}

Best Answer

The first question has already been addressed in comments.

Here, I address the second, together with the related question you asked in comments.

The template is local. But the frame on which the stray text appears is not complete when the group containing the template specification opens. So the template is set while material is being collected for that frame. When you start the next frame properly, the previous one is finished and shipped out with the background template.

If you add stray text following the frame, but before the group is closed, you can see the reverse effect. The stray text is put into a new frame. At this point, the background is active. However, the group is closed while material is still being collected for the frame. So the background setting is switched off while that material is being collected. When the next frame begins outside of the local group, the previous frame is ended and the frame is shipped out with the current, default background template.

This is easier to show than to explain...

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\begin{document}

  \section[sec]{title}
  \color{blue!75!white}
  This text is lost, so \texttt{beamer} starts a new frame (1) to collect the stray material.

  \dots collecting material for frame 1\dots

  {
    \alert{A local group is started while material is being collected for frame 1.}

    \usebackgroundtemplate{\includegraphics[width=\paperwidth]{example-image-a}}
    \alert{The background template is changed, limited by the local group.}

    When \texttt{beamer} is told to begin the \emph{next} frame i.e.\ frame 2, it will have to end this one, frame 1.

    Frame 1 will be shipped out with the current, local background.

    \begin{frame}[plain]{Title}{Subtitle}
      This is frame 2. This text is where it should be. This frame begins and ends within the local group, so it will be shipped out with the current, local background.
    \end{frame}
    This is some more lost text, so \texttt{beamer} will try to find it a home.

    Since no frame is currently in progress, a new frame, frame 3, will be started and material will be collected.

    \alert{At this point, the local background is still in place\dots but frame 3 is not yet complete\dots}
  }

  \alert{Now we are outside the local group, so the background is reset to the default.}

  When frame 4 is started, \texttt{beamer} will finish frame 3 and ship it out with the current, non-local background.
  \begin{frame}[plain]{Another Frame}
    This is frame 4. This frame begins and ends outside the local group so it will be shipped out with the non-local background now current.
  \end{frame}   

\end{document}

group framing effects