josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.35k stars 139 forks source link

overlayarea takes space even with height 0 #868

Closed gqqnbig closed 7 months ago

gqqnbig commented 7 months ago
\documentclass{beamer}

\begin{document}
\begin{frame}[t]
%
\begin{overlayarea}{0pt}{0pt}\gdef\x{Hello}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\gdef\y{World}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}something else\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
%
\x \y

\end{frame}
\end{document}

The output is this

texstudio_JDEHidq81h

The environment overlayarea certainly occupies space.

But since I specify the height 0pt, it should in my opinion take 0pt height.

Can you fix this bug?

samcarter commented 7 months ago

You can switch off the space between new lines like this:

\documentclass{beamer}

\begin{document}
\begin{frame}[t]

\offinterlineskip
\begin{overlayarea}{0pt}{0pt}\gdef\x{Hello}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\gdef\y{World}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}something\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}%
\begin{overlayarea}{0pt}{0pt}\end{overlayarea}
\strut\color{red}\x \y

\end{frame}
\end{document}

document-1

gqqnbig commented 7 months ago

beameruserguide only says "Everything within the environment will be placed in a rectangular area of the specified size."

Probably my fundamentals are not solid, but the user guide doesn't mention the margin of the rectangular area.

Can you add some text like "the margin (or line skip) of the area is determined by xxxx, even if you specify the height of the area to 0pt"?

davidcarlisle commented 7 months ago

The overlay area is not adding a margin, the space is the space added in the source file, just as X X is wider than XX or closer to the example

X
X

is wider than

X%
X

Here the letter X is not adding a mrgin it just has or does not have a space after it. The overlay area is the same (except it has no width)

gqqnbig commented 7 months ago

The command \offinterlineskip for sure works like a charm. It's defined in latex2e to change a bunch of lineskip thingummy.

Is my understanding correct that overlayarea will create a paragraph and vertical space will be created?

I'm not sure whether all environments in latex create a paragraph, if not, probably it's worth noting it in the user guide.

samcarter commented 7 months ago

overlayarea internally uses a \vbox, so it basically boils down to https://tex.stackexchange.com/questions/274147/extra-interline-glue-between-vboxes