Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
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 at 9:18
    
thanks, indeed, that is the answer... –  Maïeul Aug 26 at 9:21

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
thanks a lot... –  Maïeul Aug 26 at 9:33
    
nice and elaborate answer as usual. :-) –  Harish Kumar Aug 26 at 10:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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