[comp.text] TeX \vbox trouble

walters@oksce1.okstate.edu (Harold G. Walters) (12/07/89)

I'm trying to make an exactly 1 inch \vbox with text set in
paragraph mode along the bottom of the \vbox. Like

------------------------------------------



Text goes along the
bottom
------------------------------------------

with the macro

\long\def\oneline#1{\vbox to 1.0in{     
\vfil{#1}
}} 

Which works fine when the bottom line does not have descenders,
BUT if the bottom line has descenders like

------------------------------------------



Text goes along the
bottom with descenders like ygp
------------------------------------------

The actual size of the box is greater than 1 inch by an amount
of the depth of the descenders.  I guess the \vbox is calculating
the height based on the baseline of the text inside.

IS this what is happening?
WHY does is happen this way, it seems like a \vbox should contain
	all of its contents in their entirety?
COULD someone tell me how to fix it?




-- 
Harold G. Walters			walters@1.ce.okstate.edu
School of Civil Engineering		okstate!oksce1!walters
Oklahoma State University		"If all you have is a hammer, 
Stillwater, OK  74078			 everything looks like a nail".

piet@cs.ruu.nl (Piet van Oostrum) (12/08/89)

In article <272@oksce1.okstate.edu>, walters@oksce1 (Harold G. Walters) writes:
 `
 `I'm trying to make an exactly 1 inch \vbox with text set in
 `paragraph mode along the bottom of the \vbox. Like
 `

 `\long\def\oneline#1{\vbox to 1.0in{     
 `\vfil{#1}
 `}} 
 `
 `Which works fine when the bottom line does not have descenders,
 `BUT if the bottom line has descenders like
 `
 `The actual size of the box is greater than 1 inch by an amount
 `of the depth of the descenders.  I guess the \vbox is calculating
 `the height based on the baseline of the text inside.
 `
 `IS this what is happening?
 `WHY does is happen this way, it seems like a \vbox should contain
 `	all of its contents in their entirety?
 `COULD someone tell me how to fix it?
 `
Look into the TeXbook, chapter 12, the paragraph just below exercise 12.10.

I think this is done so that you can align a few vboxes next to each other
with the texts coming out on equal height.

I think you can do something like this: put the text in a \vbox with
\boxmaxdepth set to 0, and then put that in the 1 inch \vbox.
Read page 81 of the TeXbook.
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-531806   Uucp:   uunet!mcsun!hp4nl!ruuinf!piet
Telefax:   +31-30-513791   Internet:  piet@cs.ruu.nl   (*`Pete')

peter@memex.co.uk (Peter Ilieve) (12/12/89)

I tried mail but it bounced, so I will burden everyone with this.

In article <272@oksce1.okstate.edu>
walters@oksce1.okstate.edu (Harold G. Walters) writes:
>
>I'm trying to make an exactly 1 inch \vbox with text set in
>paragraph mode along the bottom of the \vbox.
>
>with the macro
>
>\long\def\oneline#1{\vbox to 1.0in{     
>\vfil{#1}
>}} 
>
>BUT if the bottom line has descenders like
>
>The actual size of the box is greater than 1 inch by an amount
>of the depth of the descenders.  I guess the \vbox is calculating
>the height based on the baseline of the text inside.
>
>IS this what is happening?

Yes, the 1.0in does not include the depth of the text.

>WHY does is happen this way, it seems like a \vbox should contain
>	all of its contents in their entirety?

The box still does contain its contents. The problem is that a \vbox has both a
height and a depth. The "\vbox to 1.0in" construct is DEFINED as only affecting
the height, that's just how TeX is.

>COULD someone tell me how to fix it?

The rules for setting the depth of a \vbox are explained in a "double
dangerous bend" section in Chapter 12 of the TeXbook (page 80 in mine).
One simple thing that will fix it is to put a \vskip 0pt after the {#1}
in your macro definition. A \vbox that has at least one internal box
(the text in your case) gets set with zero depth if the final box is
followed by kerning or glue.

I have tried this here and it works, changing the box in your example from
\vbox(72.26999+1.94444)x469.75499 to \vbox(72.26999+0.0)x469.75499.

	Peter Ilieve		peter@memex.co.uk