# Overlay an Entire Slide with a Semitransparent Rectangle in Beamer

Using tikz to overlay an entire slide with a semitransparent rectangle is a nice gimmick in presentations. There is only one drawback: If the theme that has a footer, the footer is not covered by the rectangle which looks kinda ulgy as you can see here:

Using a theme without a footer is obviously a workaround, but it would be even nicer if the rectangle would cover the whole slide. Any ideas how this could be done?

Here is the code:

\documentclass{beamer}
\usepackage{tikz}
\usetheme{Copenhagen}

\newcommand<>{\overlay}[1]{\uncover#2{%
\begin{tikzpicture}[remember picture,overlay]%
\draw[fill=black,opacity=0.70]
(current page.north east) rectangle (current page.south west);
\node at (current page.center) {#1};
\end{tikzpicture}}
}

\begin{document}
\section{Beamer}
\begin{frame}{Beamer}
Some text
\overlay<2>{
\huge \textcolor{white}{
\begin{minipage}{.8\linewidth}
\begin{block}{Really Important}
Some thing one should always KEEP in mind.
\end{block}
\end{minipage}
}
}
\end{frame}
\end{document}

-
Maybe, adding some extra offset just to make sure you cover it? –  percusse Feb 22 '12 at 16:48
After some experiment, I think the footline is printed over the slide contents. So it's not a positioning but an order of drawing problem. –  percusse Feb 22 '12 at 17:04
@percusse, I think so too. It seems as if beamer draws the footer after the main content. –  maetra Feb 22 '12 at 17:13
This might be useful on understanding how a frame is built up: tex.stackexchange.com/q/26299/86, though I notice that it doesn't quite explain what's going on here. The footline stuff is in the footer, which is placed after the content of the page, whence on top. So if you want a transparent rectangle over the whole lot, it'll have to go in the footer. This is definitely possible. Exactly how easy depends on what templates beamer has for the footer. –  Andrew Stacey Feb 22 '12 at 19:02

This is possible by hooking in to the footline template. Fortunately, beamer provides the \addtobeamertemplate command so once the theme has been loaded it is straightforward to add some extra code there. With the mechanics sorted, the next question is as to how to make it easy to use. What I decided to do (though there may well be other methods) was to use the \addtobeamertemplate to place an overlaid tikzpicture as the last thing on the page. Then I provide a macro which can place things in this picture. This is cleared every slide, so using overlay specifications it is to control what appears on each slide. Here's an example (hopefully it's clear from the pictures that the overlay really does cover everything. Setting the fill colour to something like pink makes it even clearer):

\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/45420/86}
\usepackage{tikz}
\usetheme{Copenhagen}

\makeatletter
\def\ft@overlay{}

{%
\lineskiplimit0pt
\begin{tikzpicture}[remember picture,overlay]%
\ft@overlay
\end{tikzpicture}%
\gdef\ft@overlay{}%
}

\only#2{%
\expandafter\gdef\expandafter\ft@overlay\expandafter{\ft@overlay #1}%
}%
}

\makeatother

\begin{document}
\section{Beamer}
\begin{frame}{Beamer}
Some text
\pause
\draw[fill=black,opacity=0.70]
(current page.north east) rectangle (current page.south west);
\node[text=white,font=\Huge] at (current page.center) {Overlaid};
}
\pause
And yet more text
\end{frame}
\end{document}


-
Ah, so it is called \addtobeamertemplate! I was searching for an append command. –  percusse Feb 22 '12 at 19:31
@percusse This one was new for me this time: previously I've done similar things by overwriting the template, but adding to it is much neater. (The mysteries of beamer templates are still mysteries to me.) –  Andrew Stacey Feb 22 '12 at 20:00
@AndrewStacey, I just found out that if I add some more text in the overlayed slide, linespacing doesn't seem to be correct. See for example this \begin{minipage}{.8\linewidth} \begin{block}{Really Important} Some thing one should always KEEP in mind.\end{block} The \linespread command does not have any effect. Adding \\ \vspace{} does work, but it is kinda annoying to add it after each line. –  maetra Feb 25 '12 at 10:02
@maetra Can you edit a full example into your question? I'm not clear as to where you are adding this. –  Andrew Stacey Feb 25 '12 at 11:07
@AndrewStacey, I hope everything is clear now. If you compare the layout of the minipage using the code from my MWE and your MWE, you see that in the latter the g from thing almost touches the second E in KEEP. –  maetra Feb 25 '12 at 13:06