2

I need to insert an image to one slide without any padding. Other slides should remain untouched.

My code looks like:

\begin{frame}{Some title here}
    \begin{figure}[h!]
        \includegraphics[width=400px]{800x400.png}
    \end{figure}
\end{frame}

Current behaviour: enter image description here

Expected behavior:

enter image description here

Is it possible without big code change in template files?

2

Welcome to TeX-SE! The figure environment does not help to accomplish this. According to how I read the question you want not to respect the left margin, so you could just use TikZ, which, when used with overlay, allows you to put stuff wherever you want.

\documentclass{beamer}
\usetheme{Rochester}
\usepackage{tikz}
\defbeamertemplate{background canvas}{my background pic}%
[2][width=\paperwidth]
{\tikz[remember picture,overlay]{
\node[overlay,inner sep=0pt,outer sep=0pt,anchor=north west] at 
([yshift=\the\textheight+0.8ex]current page.south west)
{\includegraphics[#1]{#2}};}}
[action]{}


\begin{document}
\setbeamertemplate{background canvas}[my background pic]{example-image-a}
\begin{frame}[t]
\frametitle{Some title here}
\end{frame}

\setbeamertemplate{background canvas}[my background pic]{example-image-duck}
\begin{frame}[t]
\frametitle{Don't fry ducks}
\end{frame}

\end{document}

enter image description here

  • Thanks that's great. Could you please edit/explain the code a little bit. It doesn't work for me when I insert code like \setbeamertemplate{background canvas}[myimage.png]. I must remove all occurrences of my background pic and example-image-a with myimage.png in order to make it work. Also, I tried to insert image but the top marging/padding stays there. See image: pasteboard.co/IhwkgrO.png – Joozty Jun 2 at 8:04
  • 1
    @Joozty If you want to change the picture, you need one more argument, the name of the graphics file. I added an example. You could add more arguments. Also in this version the aspect ratio of the pictures is not not changed. If you want to fill the full page, you need to add an appropriate height but this will distort the pictures and does IMHO not look good. – user121799 Jun 2 at 8:09
  • I want to insert an image in the top left corner (header and footer should stay) and try to fill the whole slide. If the image is too small there should be a blank bar at the bottom. If the image is bigger it should be cropped. Basically, the width should be 100% (already set) and height should be adjusted to respect ration. I tried to insert a very big image and it seems to be inserted in the other way around - the starting point is bottom left or right corner because my image got cropped from the top. See pasteboard.co/IhwtDSb.png. – Joozty Jun 2 at 8:29
  • 1
    @Joozty I updated the answer accordingly. – user121799 Jun 2 at 12:39
  • 1
    @Joozty The cleaner way is probably tex.stackexchange.com/a/142989/121799 . – user121799 Jun 2 at 20:21

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.