# overprint environment from beamer not working with graphbox

I create a presentation with pdfLaTeX and the beamer document class. In the presentation graphics are shown step by step. The graphic for each step replaces the graphic from the preceding step. To this end, I use beamer's overprint environment.

\nonstopmode
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{mwe} % provides example-image-*
%\usepackage{graphbox}

\begin{document}
\begin{frame}[plain]{}
before
\pause
\begin{overprint}
\onslide<+|handout:0>\includegraphics[width=1cm]{example-image-a}
\onslide<+|handout:0>\includegraphics[width=1cm]{example-image-b}
\onslide<+-|handout:1>\includegraphics[width=1cm]{example-image-c}
\end{overprint}
\end{frame}
\end{document}


This works well. I get the following four slides:

However, as soon as I add the package graphbox the example above stops working, that is, the generated PDF is not what I want. There is an additional slide and all but the last slide contain no graphic:

I really would like to use graphbox because of its easy vertical alignment (\includegraphics[align=c]). Is there a way to make graphbox work with overprint?

The graphbox package redefines \includegraphics such that the included picture always occupies space (even if not visible). This changes the behavior of beamer overlays (see Sections 1.3 and 2.2 of the package manual) and causes your problem. Add the option nobeamer to the graphbox package to disable this behavior.
\usepackage[nobeamer]{graphbox}

• Thank you, worked like a charm. With graphbox' default behavior it might even be possible to cope without overprint using \only instead of \onslide. – Socowi Nov 10 '19 at 22:25