File: FAQ-findwidth.html

package info (click to toggle)
texlive-doc 2007.dfsg.2-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 129,872 kB
  • ctags: 3,330
  • sloc: xml: 23,147; perl: 8,370; makefile: 843; sh: 352; lisp: 276; java: 159; python: 97; sed: 4
file content (27 lines) | stat: -rw-r--r-- 973 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<head>
<title>UK TeX FAQ -- question label findwidth</title>
</head><body>
<h3>Finding the width of a letter, word, or phrase</h3>
<p>Put the word in a box, and measure the width of the box. For example,
<blockquote>
<pre>
\newdimen\stringwidth
\setbox0=\hbox{hi}
\stringwidth=\wd0
</pre>
</blockquote><p>
Note that if the quantity in the <code>\</code><code>hbox</code> is a phrase, the actual
measurement only approximates the width that the phrase will occupy in
running text, since the inter-word glue can be adjusted in paragraph
mode.
<p>The same sort of thing is expressed in LaTeX by:
<blockquote>
<pre>
\newlength{\gnat}
\settowidth{\gnat}{\textbf{small}}
</pre>
</blockquote><p>
This sets the value of the length command <code>\gnat</code> to the width of &ldquo;small&rdquo;
in bold-face text.
<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=findwidth">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=findwidth</a>
</body>