
The ECN No Name Newsletter is no longer being published. This is an archived issue.
[previous article] [next article]Troff has lots of different fonts. The advent of smarter laser printers has made the selection of fonts a virtual smorgasbord of variations for users. Everything but underlining. We do not have this font option for our printers.
If you can recall the "good old days" when you used nroff on an impact printer for text processing and anytime you specified "\" to italicize a word it came out underlined because nroff could not do italics. Nroff also used overstriking to produce a bold look. With troff you actually get bold and italics! When first switching from nroff to troff if you were really trying to underline text, it can be disconcerting to get italics instead!
One method to underline with troff is to define a macro. You can copy this definition of the ".us" macro into your header to achieve underlining:
.de us \" define underscoring
\\$1\v'0.1m'\1'|0\(ul'\v'-0.1m
..
If you have this line in your file:
.so /usr/lib/tmac/tmac.m
you need to make sure you put the ".us" macro in after that line. The usage of this macro is:
.us "text"
or with a phrase:
.us "word word word"
This macro will only underline on one line at a time, so it is best used for short phrases. In the example above where multiple words are to be underlined, using a backslash-space, instead of just a space, will allow troff to calculate the space width correctly. The number, 0.1m and .25m, in the examples shown adjust the placement of the underlining in relation to the text.
If you wish to use automatically numbered headings (.HU, .H 1, etc.) then you may have a heading underlined by using another definition called ".ds l ". ("ell", not one!)
.\" Define 'l' to underline text preceding it .ds l \v'.25m'\l'|0\(ul'\v'-.25m'
Note that the underlining of those headings is repeated in the table of contents if the ".TC" macro is used. One usage: .H 1 "Main Heading" would produce:
1. Main Heading
------------