[Tex/LaTex] beamer: How to place images behind text (z-order)


When writing a beamer presentation, I often use textblocks containing a single includegraphics to place pictures freely on a slide, e.g.


Unfortunately, images are alwyas placed above the textbody of the slide with respect to the z-order, i.e. the pictures overlap and cover the text. Sometimes this is very inconvenient, especially if the picture itself is not square-shaped.

I read about using beamer background templates as a solution, but this not work in my case. Our corporate beamer style also uses background templates which interferes with this solution. Moreover, using textblocks does not seem to work inside a beamer background template.

I also read about wrapping everything in tikz to get the correct z-order. But this additional layer code is also very inconvient when you need it on every other slide.

So, is there an easier solution to place pictures anywhere on the slide and have them behind the text?

Best Answer

You can define a custom environment backgroundblock like this:


% For demonstration purposes only, can be removed without harm

% beamer: How to place images behind text (z-order)
% (http://tex.stackexchange.com/a/134311)
    \vbox to0pt\bgroup\vskip#2\hbox to0pt\bgroup\hskip#1\relax%


It is used very much like the textpos environment textblock(*) in absolute mode, i. e.


places <Content> in a box at the coordinates (<hpos>,<vpos>) relative to the top left corner of the slide.

example slide with two backgroundblock environments

Explanation of the code

A box \@backgroundblock is added to the beamer template background which is later filled by the content of the backgroundblock environments. This shouldn't interfere with custom themes, as it is ensured that the box doesn't any occupy any space.