Next: , Previous: , Up: gtroff Reference   [Contents][Index]


5.10 Tabs and Fields

A tab character (ASCII char 9, EBCDIC char 5) causes a horizontal movement to the next tab stop (much like it did on a typewriter).

Escape: \t

This escape is a non-interpreted tab character. In copy mode (see Copy-in Mode), \t is the same as a real tab character.

Request: .ta [n1 n2nn T r1 r2rn]
Register: \n[.tabs]

Change tab stop positions. This request takes a series of tab specifiers as arguments (optionally divided into two groups with the letter ‘T’) that indicate where each tab stop is to be (overriding any previous settings).

Tab stops can be specified absolutely, i.e., as the distance from the left margin. For example, the following sets 6 tab stops every one inch.

.ta 1i 2i 3i 4i 5i 6i

Tab stops can also be specified using a leading ‘+’, which means that the specified tab stop is set relative to the previous tab stop. For example, the following is equivalent to the previous example.

.ta 1i +1i +1i +1i +1i +1i

gtroff supports an extended syntax to specify repeat values after the ‘T’ mark (these values are always taken as relative) – this is the usual way to specify tabs set at equal intervals. The following is, yet again, the same as the previous examples. It does even more since it defines an infinite number of tab stops separated by one inch.

.ta T 1i

Now we are ready to interpret the full syntax given at the beginning: Set tabs at positions n1, n2, …, nn and then set tabs at nn+r1, nn+r2, …, nn+rn and then at nn+rn+r1, nn+rn+r2, …, nn+rn+rn, and so on.

Example: ‘4c +6c T 3c 5c 2c’ is equivalent to ‘4c 10c 13c 18c 20c 23c 28c 30c …’.

The material in each tab column (i.e., the column between two tab stops) may be justified to the right or left or centered in the column. This is specified by appending ‘R’, ‘L’, or ‘C’ to the tab specifier. The default justification is ‘L’. Example:

.ta 1i 2iC 3iR

Some notes:

The read-only number register .tabs contains a string representation of the current tab settings suitable for use as an argument to the ta request.

.ds tab-string \n[.tabs]
\*[tab-string]
    ⇒ T120u

The troff version of the Plan 9 operating system uses register .S for the same purpose.

Request: .tc [fill-glyph]

Normally gtroff fills the space to the next tab stop with whitespace. This can be changed with the tc request. With no argument gtroff reverts to using whitespace, which is the default. The value of this tab repetition character is associated with the current environment (see Environments).15

Request: .linetabs n
Register: \n[.linetabs]

If n is missing or not zero, enable line-tabs mode, or disable it otherwise (the default). In line-tabs mode, gtroff computes tab distances relative to the (current) output line instead of the input line.

For example, the following code:

.ds x a\t\c
.ds y b\t\c
.ds z c
.ta 1i 3i
\*x
\*y
\*z

in normal mode, results in the output

a         b         c

in line-tabs mode, the same code outputs

a         b                   c

Line-tabs mode is associated with the current environment. The read-only register .linetabs is set to 1 if in line-tabs mode, and 0 in normal mode.


Next: , Previous: , Up: gtroff Reference   [Contents][Index]