[Tex/LaTex] Full width image in beamer

beamergeometrymargins

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.

Best Answer

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]{example-image}
\end{frame} 

\end{document}

enter image description here