-->
Previous Table of Contents Next


You can see that the numbers usually line up with the decimal point in a vertical row, except where moved over by the \& characters. Even if a number has no decimal point specified (as in the second line of the example), it is lined up as though one were present after the last digit.

The following are a few additional keyletters that can be used to create special formats and make the tables more attractive:

_ Horizontal line in place of column entry.
= Double horizontal line in place of column entry.
| Between column entries, draws a vertical line between columns. Before the first keyletters, draws a line to the left of the table. After the last keyletters, draws a line to the right of the table.
| | Between column entries, draws a double vertical line.
e/E Sets equal width columns. All columns that have a keyletter followed by e or E are set to the same width.
f/F Followed by a font name or number, changes the entry to the font specified.
n Any number following a keyletter. Indicates the amount of separation between columns.
p/P Followed by a number, changes the point size of the entry to the specified number. Increments acceptable.
t/T Vertically spanned items begin at the top line. Normally, vertically spanning items (more than one line in the table) are centered in the vertical range.
v/V Followed by a number, gives vertical line spacing.
w/W Followed by a number, sets the width.

The order of these characters on the format line is not important, although the spacing between each format identifier must still be respected. Multiple letters can be used. The entry


np14w(2.5i)fi

sets the numeric entry (n) in italics (fi), with a point size of 14 (p14) and a minimum column width of 2.5 inches (w(2.5i)).

You may need to change the format of a table midway through—for example, to present summaries. If you must change the format, use the .T& (table continue) command.

Data

Data for the table is entered after all the format specifications have been completed. Data for columns is separated by tabs or any other character indicated in the tabs option. Each line of data is one line of the table. Long lines of data can be broken over several lines of source by using the backslash character as the last character in a line.

Any line starting with a period and followed by anything other than a number is assumed to be a groff command and is ignored by the preprocessor. If a single line of the data consists of only underscore or equal sign characters (single and double lines), it is treated as extending the entire width of the table.

You can embed a block of text within a table by using the text commands of T{ (start of text) and }T (end of text). This lets you enter something that can’t be easily entered as a string separated by tabs.

Examples

The best way to understand how to use gtbl is to look at some simple examples. Here’s a basic table command:


.TS

doublebox;

c c c, l l n.

Name           Dept      Phone

Joe            8A        7263

Mike           9F        2635

Peter          2R        2152

Yvonne         2B        2524

.TE

All of the entries in the data section are separated by tabs. This produces a table with three columns, the first line of which is centered text. The rest of the table has the first and second columns left-justified and the last column aligned by decimal point (there are none in this case). The entire table is surrounded by two boxes.

A slightly more complex example uses a table title followed by a row of column headings and then the data. Separate each element in the table by a box in this case:


.TS

allbox;

c s s

c c c

n n n .

Division Results

East           West      North

15             12       14

12             12       18

36             15       24

.TE

Try typing in these examples, or create your own, to see what effect the different commands have. When you’ve started using gtbl, it isn’t that difficult.

Summary

Although word processors have made utilities such as geqn and gtbl less popular than they used to be, some diehard UNIX people still like to use them. There may be times when you can’t produce an equation the way you want with your favorite word processor, so you might have to return to the basics. Also, because word processors capable of fancy formulas tend to be expensive, utilities such as geqn and gtbl are ideal for the occasional user who doesn’t want to spend a lot of money on a seldom-used tool. From here, you can learn more about using:

gawk, a handy and quick programming language for advanced users and system administrators, in Chapter 25, “gawk.”
Perl, another programming language that is very popular for Web-based scripting in Chapter 28, “Perl.”
Smalltalk/X, an X-based implementation of the object-oriented programming language, in Chapter 31, “Smalltalk/X.”


Previous Table of Contents Next