5

Specifying both a background color and a background image for beamer slides is a bit tricky when notes are shown. I tried three approaches but none works perfectly (the idea is to avoid white borders above and below a full-screen image).

The first solution was inspired by this answer :

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}

\begin{document}

{
\setbeamercolor{background canvas}{bg=red}
\setbeamertemplate{background canvas}{
  \parbox[c][\paperheight][c]{\paperwidth}{
    \centering\includegraphics[width=\paperwidth]{name}
  }
}
\begin{frame}[plain]
\end{frame}
}

\end{document}

But setting the background color has no effect. I also tried to include the graphics inside the frame but the image is not centered anymore :

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}

\begin{document}

{
\setbeamercolor{background canvas}{bg=red}
\begin{frame}[plain]
\parbox[c][\paperheight][c]{\paperwidth}{
  \centering\includegraphics[width=\paperwidth]{name}
}
\end{frame}
}

\end{document}

My last test is based on this answer :

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}

\usepackage{tikz}
\usepackage{pgfpages}

\setbeameroption{show notes on second screen=right}\nofiles

\begin{document}

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

{
\setbeamercolor{background canvas}{bg=red}
\begin{frame}[plain]
\begin{tikzpicture}[remember picture,overlay]
\node[at=(current page.center)] {
  \includegraphics[width=\paperwidth]{name}
};
\end{tikzpicture}
\note{Note}
\end{frame}
}

\end{document}

But the image is not positioned correctly when notes are shown (even with the nofiles trick).

Each solution has a distinct problem. Any idea on one possible fix?

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – user11232 Oct 25 '13 at 9:19
  • Thanks for the information. I will try my best to stick to it. I was actually wondering whether I should present all my investigations in the question (it makes the question unnecessary long and it can even be seen at three separate questions). – Louis-Claude Canon Oct 25 '13 at 19:39
4

The default background canvas is defined as

\defbeamertemplate*{background canvas}{default}
{%
  \ifbeamercolorempty[bg]{background canvas}{}{\color{bg}\vrule width\paperwidth height\paperheight}%
}

So it just draws a box filling the whole frame with the background canvas color. That's why changing the background canvas color does not have any effect anymore, if the default background canvas is overwritten.

But there is another background layer simply called background which is drawn on top of the background canvas. After changing \setbeamertemplate{background canvas} to \setbeamertemplate{background} the first solution works.

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}

\begin{document}

{
\setbeamercolor{background canvas}{bg=red}
\setbeamertemplate{background}{%
  \parbox[c][\paperheight][c]{\paperwidth}{%
    \centering\includegraphics[width=\paperwidth]{name}
  }
}
\begin{frame}[plain]
\end{frame}
}

\end{document}

The second solution doesn't work because every beamer frame has a text margin left (and text margin right) and this shifts the image in this case to the right because with its width of \paperwidth it doesn't fit inside anymore. To solve the issue here one could shift it back using \hspace with a negative length. In this case it is \hspace*{-1cm}.

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}

\begin{document}

{
\setbeamercolor{background canvas}{bg=red}
\begin{frame}[plain]
\hspace*{-1cm}%
\parbox[c][\paperheight][c]{\paperwidth}{
  \centering\includegraphics[width=\paperwidth]{name}
}
\end{frame}
}

\end{document}
| improve this answer | |
  • The proposed fix to the first solution works and the third solution mentioned in the question also works now. – Louis-Claude Canon Aug 29 '19 at 14:48

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.