Full width image in beamer?

I have a beamer presentation with a custom style which creates a red bar along the bottom of each slide. When I change the geometry and then revert it with restoregeometry, the red bar is now shifted to the right. The aim is just to have the picture full width.

\documentclass{beamer}
\mode<presentation>
{
\usetheme{myslides}
}

\begin{document}

\begin{frame}[fragile]
\frametitle{}

\begin{center}
\huge Introduction?
\end{center}
\end{frame}

\newgeometry{margin=0pt}

\begin{frame}[fragile, plain]
\frametitle{}
\includegraphics[width=\paperwidth, width=\paperwidth]{picture}
\end{frame}

\restoregeometry
\begin{frame}[fragile]
\frametitle{}
\begin{center}
\huge Next slide?
\end{center}
\end{frame}
\end{document}


How can I restore back to exactly the state it was in before the newgeometry command?

My question seems related to beamer: frame without decorations, with custom margin as well where there is a similar problem with \restoregeometry in one of the answers.

• Why don't you make the changes local, as in this answer? – Jost Nov 7 '13 at 13:03

Without having access to your beamer theme nor to the image, it is difficult to test. But if you know the size of your margins the following (dirty but simple) solution might work.

\vspace*{-6.5mm}
\begin{frame}[plain]
\hspace*{-19mm}
\includegraphics[width=\paperwidth]{picture}
\end{frame}


(to be used without any geometry resetting commands)

Or without manually fiddling around with the size of the margins:

\documentclass{beamer}

\makeatletter
\newlength\beamerleftmargin
\setlength\beamerleftmargin{\Gm@lmargin}
\makeatother

\begin{document}

\begin{frame}[plain]
\hspace*{-\beamerleftmargin}%
\includegraphics[width=\paperwidth,width=\paperwidth]{example-image}
\end{frame}

\end{document}


• Thank you. I had to play with the exact size for \hspace*{-19mm} but with -7mm it worked perfectly. – felix Nov 14 '13 at 13:06
• I've been struggling with this for a long time now, thanks for \Gm@lmargin. – Ayberk Özgür Jun 11 '17 at 8:20

A plain frame with a background image can be locally applied without need for changing and restoring geometry changes

\documentclass{beamer}
\mode<presentation>
{
\usetheme{Berkeley} %<-- We don't have myslides theme
}

\begin{document}

\begin{frame}[fragile]
\frametitle{}

\begin{center}
\huge Introduction?
\end{center}
\end{frame}

{%<--- Start local changes
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{example-image}}
\begin{frame}[plain]
\end{frame}
}%<---- Finish local changes

\begin{frame}[fragile]
\frametitle{}
\begin{center}
\huge Next slide?
\end{center}
\end{frame}
\end{document}


A very simple solution using tikz:

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

\begin{frame}[plain]
\begin{tikzpicture}[remember picture,overlay]
\node[at=(current page.center)] {
\includegraphics[width=\paperwidth, height=\paperheight]{example-image}
};
\end{tikzpicture}
\end{frame}

\end{document}


[has to be compiled two times to get the coordinates right]

• It even works with rmarkdown :-) – Ott Toomet Sep 22 '17 at 18:12
• @OttToomet Good to hear! – user36296 Sep 22 '17 at 19:02

EDIT: I should have tested this in more detail before posting. It seems that the following frames have their geometry/layout modified... So please be aware that there might be some issues.

After looking at different answers and comments from different questions around this problem of beamer still having a left margin in plain frames, let me post the solution I just found, to get a really empty plain frame, no margins etc. in an easy automated generic way. In such a frame, one can do as wished, for example put a graphic that exactly takes the whole width of the frame, or center it with exactly the same left and right spaces, without having to cheat with horizontal offsets or whatever.

The problem I had was that \setbeamersize{text margin left=0pt} or the likes can't be used in a local way, it has to be in the preamble, it can't be in the body and also not in command or environment definitions.

The solution was to use \newgeometry, as used in the OPs question, from the geometry package, loaded by beamer, and restrain it locally as suggested in the comment above. And it needs no fancy stuff, no ad hoc lengths, etc.

It seems that it hasn't been posted like I am about to do, and I think it could be interesting to a wide audience (I looked long before finding it). And the only other answer I know of that needs no ad hoc ajustments, namely this one, uses little more beamer-hacking knowledge.

Solution for one isolated frame:

{newgeometry{margin=0pt} %locally set margins to zero
\setbeamertemplate{background canvas}[default] %not too sure, but may be needed if you have a background image
\begin{frame}[plain]
%frame content  that can really fill the whole page
\end{frame}
}


And if you need this on a regular basis, define it as a new environment, e.g. emptyframe, in the preamble:

\newenvironment{emptyframe}
{
% not too sure, but may be needed if you have a background image
% that should not appear on this kind of frame:
\setbeamertemplate{background canvas}[default]
% locally set margins to zero: (notice the use of \bgroup ... \egroup
% to limit the scope of the geometry restriction
% where curly brackets {} aren't possible)
\bgroup \newgeometry{margin=0cm}
\begin{frame}[plain]
}
{
\end{frame}
\egroup
}


After that, in the body of the document, use it alternatively to a frame environment:

\begin{emptyframe}
% frame content that can really fill the whole page
\end{emptyframe}


Note 1: you might also need to turn off navigation symbols. To this effect, add \setbeamertemplate{navigation symbols}{} next to \setbeamertemplate{background canvas}[default].

Note 2: this solution is not limited to getting empty frames, it is (I think, didn't test) customizable up to the limits of \newgeometry.

• This is awesome; it's by far one of the easiest ways to insert figures in beamer with \newcommand, without worrying about size or placement. – Joseph Feb 1 '18 at 12:11
• There is a missing backslash before newgeometry in the isolated frame example. – rkta May 21 at 18:06