[texhax] alignment of parbox and fbox

hh hh-brasil at bol.com.br
Wed Sep 9 01:21:28 CEST 2009

\strut is a plain TeX command and is mentioned in the TeXbook. Works in LaTeX without 
problems. Dito \vphantom.

There's a way out of this dilemma, using an important idea called a "\strut".

Plain TeX defines \strut to be an invisible box of width zero that extends
just enough above and below the baseline so that you would need no interline glue at
all if every line contained a strut.

The same is valid for hphantom and vphantom:
Even more useful than \phantom is \vphantom, which makes an invisible box
whose height and depth are the same as those of the corresponding \phantom,
but the width is zero. Thus, \vphantom makes a vertical strut that can increase a
formula's effective height or depth.

There's also \hphantom, which has the width of a \phantom, but its
height and depth are zero.

Read the old books.

From:           	Reinhard Kotucha <reinhard.kotucha at web.de>
Date sent:      	Tue, 8 Sep 2009 21:56:19 +0200
To:             	bill lam <cbill.lam at gmail.com>
Copies to:      	texhax <texhax at tug.org>,
   	hh <hh-brasil at bol.com.br>,
   	Lars Madsen <daleif at imf.au.dk>,
   	Uwe.Lück <uwe.lueck at web.de>@mfe02.daimi.au.dk
Subject:        	Re: [texhax] alignment of parbox and fbox
Send reply to:  	reinhard.kotucha at web.de

> On 8 September 2009 bill lam wrote:
>  > Thanks to Lars, hh, Uwe for help.  I can get a perfect alignment now.
>  > 
>  > I learn latex by reading the book 'A Guide to Latex' by Kopka and Daly
>  > (the 1993 edition),  There are no \vphantom or \strut mentioned in that
>  > book.  I guess that are new commands introduced later.
> Does it describe LaTeX 2e already?  If not, it's worthwhile to
> consider to buy a newer book.  If it mentions \documentstyle instead
> of \documentclass, it still describes LaTeX 2.09.  I'm wondering
> because LaTeX 2e was released in 1994.
> BTW, a more general solution to your problem is to write your own macro.
>   \newcommand{\myfbox}[1]{\fbox{\vphantom{pX}#1}}
> Note that in this example \vphantom contains two characters, one with
> a descender and one with an ascender.  The size of descenders might be
> different for letters like p, g, j, y,...  but you can put them all
> into the argument of \vphantom if you want to be sure.
> Regards,
>   Reinhard
> -- 
> ----------------------------------------------------------------------------
> Reinhard Kotucha			              Phone: +49-511-3373112
> Marschnerstr. 25
> D-30167 Hannover	                      mailto:reinhard.kotucha at web.de
> ----------------------------------------------------------------------------
> Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
> ----------------------------------------------------------------------------

More information about the texhax mailing list