The following code demonstrates how to include an image full-size. To customize it, simply change image.jpg
to the file name of the picture you want to display. If you're using a beamer
theme without a sidebar (such as the default one, Ilmenau
, AnnArbor
, ...), alter \sidebarthemetrue
to \sidebarthemefalse
.
\documentclass{beamer}
\usetheme{Marburg}
\setbeamertemplate{navigation symbols}{}
\newif\ifsidebartheme
\sidebarthemetrue
\newdimen\contentheight
\newdimen\contentwidth
\newdimen\contentleft
\newdimen\contentbottom
\makeatletter
\newcommand*{\calculatespace}{%
\contentheight=\paperheight%
\ifx\beamer@frametitle\@empty%
\setbox\@tempboxa=\box\voidb@x%
\else%
\setbox\@tempboxa=\vbox{%
\vbox{}%
{\parskip0pt\usebeamertemplate***{frametitle}}%
}%
\ifsidebartheme%
\advance\contentheight by-1em%
\fi%
\fi%
\advance\contentheight by-\ht\@tempboxa%
\advance\contentheight by-\dp\@tempboxa%
\advance\contentheight by-\beamer@frametopskip%
\ifbeamer@plainframe%
\contentbottom=0pt%
\else%
\advance\contentheight by-\headheight%
\advance\contentheight by\headdp%
\advance\contentheight by-\footheight%
\advance\contentheight by4pt%
\contentbottom=\footheight%
\advance\contentbottom by-4pt%
\fi%
\contentwidth=\paperwidth%
\ifbeamer@plainframe%
\contentleft=0pt%
\else%
\advance\contentwidth by-\beamer@rightsidebar%
\advance\contentwidth by-\beamer@leftsidebar\relax%
\contentleft=\beamer@leftsidebar%
\fi%
}
\makeatother
\begin{document}
{
\setbeamertemplate{background canvas}{%
\calculatespace%
\begin{pgfpicture}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\paperheight}}
\ifbeamercolorempty[bg]{background canvas}{}{\color{bg}\pgfusepath{fill}}
\pgftext[at=\pgfpoint{\contentleft+0.5\contentwidth}{\contentbottom+0.5\contentheight}]{\includegraphics[width=\contentwidth,height=\contentheight]{image.jpg}}
\end{pgfpicture}%
}
\begin{frame}{Header}{Sub title}
Frame content
\end{frame}
}
\end{document}
Result:

(The image used is by Steve Peter and can be downloaded at http://www.tug.org/publicity/wallpaper/.)
Explanation of the code:
1. Calculating the space available to content
These dimensions will hold the height and width available and the absolute position of the content in relation to the lower left corner of the page (which is necessary when there is a left sidebar or a footline):
\newdimen\contentheight
\newdimen\contentwidth
\newdimen\contentleft
\newdimen\contentbottom
Themes with sidebars, such as Marburg
, require some extra treatment, as there's a \vskip-1em
in the definition of the frametitle
template which distorts the calculations:
\newif\ifsidebartheme
\sidebarthemetrue
The macro \calculatespace
is the core piece which computes all the lengths defined above:
\makeatletter
\newcommand*{\calculatespace}{%
We begin with \paperheight
and subtract the height of the frame title and subtitle (code adapted from beamerbaseframe.sty
, ll. 114-129):
\contentheight=\paperheight%
\ifx\beamer@frametitle\@empty%
\setbox\@tempboxa=\box\voidb@x%
\else%
\setbox\@tempboxa=\vbox{%
\vbox{}%
{\parskip0pt\usebeamertemplate***{frametitle}}%
}%
\ifsidebartheme%
\advance\contentheight by-1em%
\fi%
\fi%
\advance\contentheight by-\ht\@tempboxa%
\advance\contentheight by-\dp\@tempboxa%
\advance\contentheight by-\beamer@frametopskip%
If it is a plain frame, this is everything that has to be taken into account. Otherwise, also subtract the height of head- and footline (cf. beamerbaseframecomponents.sty
, ll. 161-182):
\ifbeamer@plainframe%
\contentbottom=0pt%
\else%
\advance\contentheight by-\headheight%
\advance\contentheight by\headdp%
\advance\contentheight by-\footheight%
\advance\contentheight by4pt%
\contentbottom=\footheight%
\advance\contentbottom by-4pt%
\fi%
Like this, we have calculated \contentheight
and \contentbottom
. To obtain the content width, one has to subtract the width of the sidebars from \paperwidth
if it's not a plain frame (beamerbaseframesize.sty
, ll. 80-85):
\contentwidth=\paperwidth%
\ifbeamer@plainframe%
\contentleft=0pt%
\else%
\advance\contentwidth by-\beamer@rightsidebar%
\advance\contentwidth by-\beamer@leftsidebar\relax%
\contentleft=\beamer@leftsidebar%
\fi%
2. Displaying the image
We now have a macro \calculatespace
that computes all the necessary dimensions. It has to be called separately for each frame as the dimensions might change depending on whether you use titles and subtitles. The inclusion of the image is done in the background canvas
template. It is scaled to the full width and height available and placed in the middle of the content space:
\setbeamertemplate{background canvas}{%
\calculatespace%
\begin{pgfpicture}
\pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\paperwidth}{\paperheight}}
\ifbeamercolorempty[bg]{background canvas}{}{\color{bg}\pgfusepath{fill}}
\pgftext[at=\pgfpoint{\contentleft+0.5\contentwidth}{\contentbottom+0.5\contentheight}]{\includegraphics[width=\contentwidth,height=\contentheight]{image.jpg}}
\end{pgfpicture}%
}
If you don't want the image to be distorted, simply add keepaspectratio
as an optional argument to \includegraphics
.
\beamer@frametextheight
but I haven't been able to figure out how to get it to work – Mark Feb 12 '12 at 6:55\beamer@frametextheight
seems like a good way to go. I had two problems with it: 1. It seems to be defined too late, whenbeamer
actually typesets the slide. So in order to use it, you'll have to define your own version of the macro emulating its behaviour. 2. It only into account the height of the title, not the height of head- or footlines. – diabonas Feb 12 '12 at 13:36