groff: Tabs and Fields
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
(⇒Copy-in Mode), '\t' is the same as a real tab character.
-- Request: .ta [n1 n2 ... nn T r1 r2 ... rn]
-- 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 default unit of the 'ta' request is 'm'.
* A tab stop is converted into a non-breakable horizontal
movement that can be neither stretched nor squeezed. For
example,
.ds foo a\tb\tc
.ta T 5i
\*[foo]
creates a single line, which is a bit longer than 10 inches (a
string is used to show exactly where the tab characters are).
Now consider the following:
.ds bar a\tb b\tc
.ta T 5i
\*[bar]
'gtroff' first converts the tab stops of the line into
unbreakable horizontal movements, then splits the line after
the second 'b' (assuming a sufficiently short line length).
Usually, this isn't what the user wants.
* Superfluous tabs (i.e., tab characters that do not correspond
to a tab stop) are ignored except the first one, which
delimits the characters belonging to the last tab stop for
right-justifying or centering. Consider the following example
.ds Z foo\tbar\tfoo
.ds ZZ foo\tbar\tfoobar
.ds ZZZ foo\tbar\tfoo\tbar
.ta 2i 4iR
\*[Z]
.br
\*[ZZ]
.br
\*[ZZZ]
.br
which produces the following output:
foo bar foo
foo bar foobar
foo bar foobar
The first line right-justifies the second 'foo' relative to
the tab stop. The second line right-justifies 'foobar'. The
third line finally right-justifies only 'foo' because of the
additional tab character, which marks the end of the string
belonging to the last defined tab stop.
* Tab stops are associated with the current environment (⇒
Environments).
* Calling 'ta' without an argument removes all tab stops.
* The start-up value of 'gtroff' is 'T 0.5i'.
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 (⇒Environments).(1)
(⇒Tabs and Fields-Footnote-1)
-- 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.
Menu