5

When I put a text in a \vbox and \unvbox it, I have extra space between line.

Why?

See the MWE:

\documentclass{article}
\begin{document}
\newbox\titi
\newcommand{\toto}[1]{\setbox\titi=\vbox{#1}\unvbox\titi}
{\LARGE\toto{Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.}}

{\LARGE Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.}
\end{document}
  • 1
    The paragraph in the \vbox is completed when \LARGE is in effect. It isn't in the second example, because \par is after }. Add \par before } and you'll see the same baselineskip. – egreg Aug 26 '14 at 9:18
6

The code

{\LARGE Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.}

is followed by \end{document}, which does \par. However, this \par comes after the effect of \LARGE has been undone, so the baselineskip used is what's pertains to \normalsize (and the \lineskip mechanism comes into play).

In the \vbox this doesn't happen, because the end of a \vbox has an implicit \par command, which is issued when \LARGE is still in effect.

If you try

\documentclass{article}
\begin{document}
\newbox\titi
\newcommand{\toto}[1]{\setbox\titi=\vbox{#1}\unvbox\titi}
{\LARGE\toto{Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.}}

{\LARGE Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.\par}
\end{document}

you'll get the same output.

enter image description here

By the way, recall that TeX doesn't add interline glue when it does \unvbox. So with

\documentclass{article}
\begin{document}
\newbox\titi
\newcommand{\toto}[1]{\setbox\titi=\vbox{#1}\unvbox\titi}
{\LARGE Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.\par}

{\LARGE\toto{Lorem ipsum dolor amet. Sic transit gloria mundi. Fiat Lux. In principio erat verbum.}}
\end{document}

you'd get

enter image description here

  • nice and elaborate answer as usual. :-) – user11232 Aug 26 '14 at 10:44
  • We should have some knowledge base where we can collect small important facts like "TeX doesn't add interline glue when it does \unvbox" – Bananguin Jul 15 '15 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.