125

I want to insert a background image in a beamer frame and use this "frame" as a beamer frame. I want to insert different background images on different frames. Towards this end, I tried

\usebackgroundtemplate{\includegraphics[width=\paperwidth]{../images/crayons.png}}

on a specific frame to insert a background image, but I was unsuccessful. Am I missing any package? Or is there a different way of doing this?

I found this question here about inserting image but not as a background. In addition to inserting a background image, I also want to add text to the frame. (It is highly likely that I could not understand the questions correctly)

As a side note, if any of you are an Emacs org-mode users, can you please tell me a way to do this in org-beamer. I will be very thankful.

Here is a sample slide code:

\documentclass[bigger]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}

\begin{frame} \frametitle{Models} \label{sec-2_3}

\usebackgroundtemplate{\includegraphics[width=\paperwidth]{../images/crayons.png}}

\begin{itemize} \item choose training data set \item choose test data set \item choose model \item fit on training data set \end{itemize}

\end{frame}

MERose
  • 228
suncoolsu
  • 1,449
  • I know most of you can are aware, but http://www.tug.org/pipermail/texhax/2007-March/008035.html is the link from where I got the idea. – suncoolsu Dec 29 '10 at 13:35
  • Do you use latex.exe or pdflatex or ? – Display Name Dec 29 '10 at 13:40
  • I use pdflatex. You can ignore the rest if you are not an Emacs user - I actually use Emacs Org-mode to create an .org file. I user org-import to creater a beamer file. I am sorry if you are not an Emacs user. – suncoolsu Dec 29 '10 at 13:46

3 Answers3

94

alt text

I used images Sir Isaac Newton (rename it as newton.jpg) and Kitten (rename it as kitten.jpg)

The code snippet below is self-explanatory and I compiled using pdflatex.exe because of .jpg format.

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

\usepackage{graphicx}


%Global Background must be put in preamble
\usebackgroundtemplate%
{%
    \includegraphics[width=\paperwidth,height=\paperheight]{newton.jpg}%
}




\begin{document}

\begin{frame}{Introduction}
\begin{itemize}
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}


% Local background must be enclosed by curly braces for grouping.
{
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{kitten.jpg}}%
\begin{frame}{Kitten}
\begin{itemize}
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}
}

\begin{frame}{Summary}
\begin{itemize}
\item 1
\item 2
\item 3
\end{itemize}
\end{frame}

\end{document}
Display Name
  • 46,933
  • 3
    gosh \usebackgroundtemplate{}? that makes things so easy. man, i love beamer. – aeroNotAuto Mar 06 '12 at 23:00
  • 5
    This doesn't work when using a theme (i.e. Darmstadt, Madrid, Warsaw). – SigmaX May 11 '15 at 15:34
  • 1
    after using "...\usebackgroundtemplate{\includegraphics[width=\paperwidth]{kitten.jpg}}%..." how is possible to modify the opacity of the background? thanks! – Iuli Sep 26 '17 at 20:40
  • 3
    @luli nest \includegraphics[width=\paperwidth]{kitten.jpg} in \tikz\node[opacity=0.1]{...}; i.e. \usebackgroundtemplate{\tikz\node[opacity=0.1]{\includegraphics[width=\paperwidth]{kitten.jpg}};} – Chernoff Jun 20 '18 at 20:35
  • This formulation is no longer functional with more recent versions of TexLive. I am currently on version 2022, \usebackgroundtemplate{} has no effect whatsoever. – Luís de Sousa Jun 23 '23 at 14:13
66

Write \usebackgroundtemplate before the frame, not within:

\end{frame}
% Now we install the new template for the following frames:
{\usebackgroundtemplate{%
  \includegraphics[width=\paperwidth,height=\paperheight]{crayons}} 
\begin{frame}
...
\end{frame}}
% Now we install another template, effective from now on:
\usebackgroundtemplate{...}

Ensure that \includegraphics is able to find the image file, since you used ../images/crayons.png.

Edit: The \usebackgroundtemplate should be enclosed with curly braces along with frame (or frames) which it should affect

boczniak767
  • 103
  • 4
Stefan Kottwitz
  • 231,401
  • 1
    I quick question. If I don't need a background, I use a file name which doesn't exist. I am sure there is a better way of doing this. Can you pls enlighten me again? – suncoolsu Dec 29 '10 at 14:23
  • 9
    @suncoolsu: Just use an empty argument: \usebackgroundtemplate{}. – Stefan Kottwitz Dec 29 '10 at 14:56
  • 3
    @StefanKottwitz I don't know if the new syntax was present when you answered this, but from the current point of view \setbeamertemplate{background}{...} might be better. – Henri Menke Dec 31 '14 at 16:03
  • This doesn't work when using a theme (i.e. Darmstadt, Madrid, Warsaw). – SigmaX May 11 '15 at 15:34
  • 1
    How to reset it back to previous background? For example, I have set \setbeamercolor{background canvas}{bg=yellow!20} at the beginning. After the particular slide, then I use \usebackgroundtemplate{}, the background color also reset to white, instead of the yellow!20. – Chen Stats Yu Dec 06 '15 at 15:22
  • @ChenStatsYu Perhaps post it as a new question. You could add a link to here, to show the context. – Stefan Kottwitz Dec 06 '15 at 15:32
  • This formulation is no longer functional with more recent versions of TexLive. I am currently on version 2022, \usebackgroundtemplate{} has no effect whatsoever. – Luís de Sousa Jun 23 '23 at 14:19
  • 1
    @LuísdeSousa I just tested it: works with TeX Live 2022 and TeX Live 2023, tested also on TeXlive.net. With \usebackgroundtemplate I get a background image. No problem with today's downvote on this answer of 2010, but your statement is wrong. – Stefan Kottwitz Jun 23 '23 at 19:11
2
\documentclass{beamer}
\usetheme{metropolis}
\begin{document}
{
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{example-image-a}}
\begin{frame}{Title}
Content
\end{frame}
}
\begin{frame}{Title}
Content
\end{frame}
\end{document}
Bacara
  • 187