Article View: comp.text
Article #5985Re: tabstop according to longest line
From: Greg McGary
Date: Thu, 16 Mar 1989 16:57
Date: Thu, 16 Mar 1989 16:57
73 lines
3003 bytes
3003 bytes
In article <16709@cisunx.UUCP> dcarson@cisunx.UUCP (David Carson) writes:
>I need a little simple advice on alignment. I'm trying to make a letterhead
>where the address appears on the right side of the page, but is not right-
>justified. It should be left justified so that the longest line of the
>address is flush with the right margin, like so:
>
> John Doe |
> 1600 Pennsylvania Ave|
> Washington, D.C. |
> 20002 |
> margin^
>
>First I tried using \halign without success.
In order to get \halign to work the way you want, you need to be sure
to use \halign to\hsize{...} so that the table will be as wide as the
page, then you need to be sure that the tabskip glue will stretch.
This works:
\tabskip=0pt plus1fill
\halign to\hsize{#\hfil\tabskip=0pt\cr
John Doe\cr 1600 Pennsylvania Ave.\cr Washington, D.C.\cr 20002\cr}
Notice that the stretchy tabskip glue before the first column has a
higher order of infinity than the \hfil that right-justifies the
column.
I like to do letterheads that are a little fancier.
One of mine looks like this:
(919) 490-6037
Greg McGary (919) 493-5953 (FAX)
---------------------------------------------------------------------
Suite 102
4201 University Drive
Durham, NC 27707
I do it like this:
\font\rmX=cmr10
\font\biXIV=cmti10 at 14.4pt
\baselineskip=12pt\rmX
\ialign to \hsize{#\hfil\tabskip=0pt plus1fill&\tabskip=0pt#\hfil\cr
& (919) 490-6037\cr
\biXIV Greg McGary & (919) 493-5953 (FAX)\cr
\noalign{\vskip4pt\hrule\vskip4pt}
& Suite 102\cr
& 4201 University Drive\cr
& Durham, North Carolina~~27707\cr}
The two phone numbers in cmr10 have the proper interline spacing no matter
how tall the font used for the name happens to be.
>Is there a way in TeX to measure text? Then I could do something like:
>
>\dimen1=\hsize
>\advance\dimen1 by-\measure<longest line of addr> %subtract the length of text
>\settabs\+\hskip<\dimen1>&\cr
Sure, put the text into a box then use one of several box-metric primitives:
\setbox0=\hbox{<longest line of addr>}
Now,
\wd0 gives the box's width
\ht0 gives the box's height
\dp0 gives the box's depth.
-- Greg McGary
-- 4201 University Drive #102, Durham, NC 27707 voice: (919) 490-6037
-- {decvax,hplabs,seismo,mcnc}!duke!gm data: (919) 493-5953
-- gm@cs.duke.edu
Technical Details
Message-ID:
<13883@duke.cs.duke.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!ukma!xanth!mcnc!duke!romeo!gmReferences:
<16709@cisunx.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!ukma!xanth!mcnc!duke!romeo!gm From: gm@romeo.cs.duke.edu (Greg McGary) Newsgroups: comp.text Subject: Re: tabstop according to longest line Keywords: TeX, alignment Message-ID: <13883@duke.cs.duke.edu> Date: 16 Mar 89 16:57:18 GMT References: <16709@cisunx.UUCP> Sender: news@duke.cs.duke.edu Reply-To: gm@romeo.UUCP (Greg McGary) Distribution: na Organization: Duke University CS Dept.; Durham, NC Lines: 73