There I was, a-merrily tracing through the depths of beamer
's code on the trail of the Dreaded Overprint Hurler of Bexhill-on-Sea, when I came across Something Completely Different. It looked like a cross between a vbox and a centering, but horribly, horribly mutated.
Desiring to slay this monstrous beastie before it could wreak havoc, I studied it and its relatives (from a safe distance). Its behaviour is strange, but by caging it I could see some patterns in its responses to basic stimuli. Eventually, I realised that if I could but introduce some genetic mutation which temporarily switched off the \centering
gene then it could be made safe and I could resume my quest to track down the Overprint.
In less prosaic language, while investigating Overprint environment inside tikz node: unexpected alignment of content I figured out that the problem was due to the interaction between the center
environment (aka \centering
) and how beamer
implements the overprint
environment. What beamer
does is gather all the possible versions of the overprint
environment into vbox
es containing minipage
s of the prescribed width. It then sets the correct one (according to the overlay specification) but with the height and depth of the biggest one. However, if the overprint
environment is contained within a center
environment, something a little odd ensues. It would appear that the vbox
containing the minipage
environment has already taken into account the center
environment and so consists of the minipage
environment at the centre of the line, with the requisite spacing fore (and presumably aft). But when the vbox
is set, it is still within the center
environment so picks up a new indentation. This wouldn't matter, except for the fact that the vbox
's width is adjusted to the prescribed width so TeX adds yet more horizontal space to shove the vbox
back into the centre of the line (or so it thinks).
Given that all of this is going on inside a beamer
overprint environment, and I don't want to muck around with that code, the simplest solution seemed to be to turn off the \centering
just before the overprint
environment (and, given my reading of the original question, turn it back on again inside). But \centering
seems to be a one-way trap: there's \centering
, \rightragged
, \leftragged
, but no \backtonormal
.
Here's some code to play around with:
\documentclass{article}
\newbox\mybox
\begin{document}
\setbox\mybox=\vbox\bgroup\fbox{\begin{minipage}{4cm}hello
world\end{minipage}}\egroup
\centering
\wd\mybox=4cm
\fbox{\box\mybox}
\setbox\mybox=\vbox\bgroup\fbox{\begin{minipage}{4cm}hello
world\end{minipage}}\egroup
\wd\mybox=4cm
\fbox{\box\mybox}
\setbox\mybox=\vbox\bgroup\fbox{\begin{minipage}{4cm}\centering hello
world\end{minipage}}\egroup
\wd\mybox=4cm
\fbox{\box\mybox}
\fbox{\begin{minipage}{4cm}hello world\end{minipage}}
\fbox{\begin{minipage}{4cm}\centering hello world\end{minipage}}
\end{document}
Here's what I get from that:
ragged2e
provides\justifying