🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #629

Re: Width of text

#629
From: Gene C. Van Nostern
Date: Fri, 31 Jul 1992 21:32
32 lines
1581 bytes
In article <1992Jul28.193951.2901@muddcs.claremont.edu> I wrote:
>Is there any way to find the width of a bit of text in TeX?  I'd like
>a command, say \widthof, that would work like this:
>
>\newdimen\textwidth
>\textwidth=\widthof{some text}
>
>From then on, I could use \textwidth to be the width of the string
>"some text".
>
>Please respond by e-mail.
>
>Thanks,
>Gene.
>gene@icarus.claremont.edu

Thanks to all the folks who responded; your solutions worked beautifully.
The gist of most of the solutions was this:  plop whatever you want the
width of into a box, then use \wd to find the width of the box.
Specifically, to use the example above, you'd do something like this:

\def\widthof#1{\setbox73\hbox{#1}\wd73\relax}

Gene.
gene@icarus.claremont.edu

Have you seen these people?
Name              Last seen/heard from Add. Info.
Jeff Kirk         Yokota AB,Japan,1981 Fthr Clyde,Mthr Sophie,was in BSA
John W. Ewing III Las Vegas,NV,1987?   May go to UNLV, has sister Allison?
Lynn Aldrich      UNY @Albany,1990     May still be @Albany, half Korean
Any info. is appreciated.  Please respond via e-mail.
Technical Details
Message-ID: <1992Jul31.213243.22813@muddcs.claremont.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!elroy.jpl.nasa.gov!news.claremont.edu!news

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!elroy.jpl.nasa.gov!news.claremont.edu!news
From: gene@icarus.claremont.edu (Gene C. Van Nostern)
Subject: Re: Width of text
Message-ID: <1992Jul31.213243.22813@muddcs.claremont.edu>
Sender: news@muddcs.claremont.edu (The News System)
Reply-To: gene@icarus.claremont.edu
Organization: Harvey Mudd College, Claremont, CA 91711
Date: Fri, 31 Jul 1992 21:32:43 GMT
Lines: 32