Ch 11 -- Tools for Writers
UNIX Unleashed, Internet Edition
- 11 -
Tools for Writers
By David B. Horvath, CCP and Susan Peppard
The preceding chapters in this section described the heart of text formatting
and printing (processing)--nroff, troff, and related macros. In
this chapter, I show you many of the commands that UNIX provides to support writers.
These commands are as follow:
- tbl: Formatting tables
- eqn/neqn: Formatting equations for troff/nroff
- pic: Drawing pictures
- grap: Creating graphs
- cw: Formatting programs in a fixed font
- refer: Building literature references
- ptx and mptx: Building permutated indexes
- spell and ispell: Checking for spelling mistakes
- diction, explain, and style: Checking grammar
- grep: Searching for text
- sed: Global editing of text
- diffmk: Marking changed text'
- man: Getting more information
- SCCS: Controlling document source
- deroff: Removing troff requests from text
Not all these commands are available with all versions of UNIX. When you're in
doubt, check the man page or contact your system administrator.
Preprocessors for nroff and troff
A number of the tools for writers are actually preprocessors. You describe the
object you are building using the language specific to that tool. The tool takes
your input and creates output that nroff or troff can process.
These tools evolved because the syntax of nroff and troff can be
so complicated.
These preprocessors are as follow:
- tbl: Formatting tables
- eqn/neqn: Formatting equations for troff/nroff
- pic: Drawing pictures
- grap: Creating graphs
- cw: Formatting programs in a fixed font
- refer: Building literature references
- ptx and mptx: Building permutated indexes
Formatting Tables with tbl
tbl is a troff preprocessor used to create tables (columns of
data with headings). The code you write is processed by tbl before the file
is processed by troff. Often, you pipe the tbl output of a file
into troff as follows:
tbl filename | troff -options
tbl takes as input the commands between each .TS/.TE macro pair
and converts the input into a printable table. All other input is passed through
without modification.
The general format of a table is as follows (don't try to process this through
tbl):
.TS H
global option;
formatting options 1
formatting options 2.
Column 1 title [tab] column 2 title [tab] column 3 title
.TH
Col 1 Item 1 [tab] Col 2 Item 1 [tab] Col 3 Item 1
Col 1 Item 2 [tab] Col 2 Item 2 [tab] Col 3 Item 2
.TE
You use the H option on .TS when the table might cross page
boundaries, and you want the column titles to print on each page. You place the .TH
macro after the column titles to separate them from the actual data values. If the
table will definitely fit on one page, you can omit the H option on .TS
and the .TH.
The global option; can be any one of the values shown in Table 11.1.
Note that the ; line terminator is required. The default, with no global
option; specified, is to create the table flush with the left margin.
Table 11.1. tbl global options.
Option |
Description |
allbox |
Puts each table item in a box (grid) |
box |
Draws a box around the table |
center |
Centers the table on the current page |
delim(xy) |
Changes eqn/neqn delimiters to x and y |
doublebox |
Draws a double box (created with two lines) |
expand |
Expands the table to the full page width |
linesize(n) |
Changes the line point size to n |
tab(x) |
Changes the column separator to x |
You must have at least one line of formatting options (which apply to the entire
table). If you specify multiple lines of formatting options, the first applies to
the column headers, and the last lines apply to the table items themselves. You can
have multiple lines of column headings and multiple lines of column formatting options.
The period . at the end of the last line of formatting options is required.
Table 11.2 shows the available formatting options; note that they are not case sensitive.
You should have one option per column.
Table 11.2. tbl formatting options.
Option |
Description |
^ |
Spans column vertically |
| |
Separates columns with single vertical line |
|| |
Separates columns with double vertical line |
a |
Indicates an alphabetic column (indent one em) |
b |
Changes to bold font |
c |
Centers the column |
e |
Equalizes width of columns |
fF |
Changes font to F |
i |
Changes to italic font |
l |
Left-justifies column |
n |
Indicates a numeric column (aligns on decimal point) |
N |
Spaces between columns in ens (default is 3) |
pN |
Change font point size to N |
r |
Right-justifies column |
s |
Spans column horizontally |
vN |
Changes vertical spacing to N |
w(N) |
Specifies column width to N |
TIP: The a option does not work
properly in older versions of tbl. Use |