TBL(1) | General Commands Manual | TBL(1) |
NAME
tbl - format tables for troffSYNOPSIS
[-Cv] [files ...]DESCRIPTION
This manual page describes the GNU version of tbl, which is part of the groff document formatting system. tbl compiles descriptions of tables embedded within troff input files into commands that are understood by troff. Normally, it should be invoked using the -t option of groff. It is highly compatible with Unix tbl. The output generated by GNU tbl cannot be processed with Unix troff; it must be processed with GNU troff. If no files are given on the command line or a filename of - is given, the standard input is read.OPTIONS
- -C
- Enable compatibility mode to recognize .TS and .TE even when followed by a character other than space or newline. Leader characters (\a) are handled as interpreted.
- -v
- Print the version number.
USAGE
tbl expects to find table descriptions wrapped in the .TS (table start) and .TE (table end) macros.Global options
The line immediately following the .TS macro may contain any of the following global options (ignoring the case of characters – Unix tbl only accepts options with all characters lowercase or all characters uppercase), separated by spaces, tabs, or commas:- allbox
- Enclose each item of the table in a box.
- box
- Enclose the table in a box.
- center
- Center the table (default is left-justified). The alternative keyword name centre is also recognized (this is a GNU tbl extension).
- decimalpoint(c)
- Set the character to be recognized as the decimal point in numeric columns (GNU tbl only).
- delim(xy)
- Use x and y as start and end delimiters for eqn(1).
- doublebox
- Enclose the table in a double box.
- doubleframe
- Same as doublebox (GNU tbl only).
- expand
- Make the table as wide as the current line length (providing a column separation factor). Ignored if one or more `x' column specifiers are used (see below).
- In case the sum of the column widths is larger than the current line length, the column separation factor is set to zero; such tables extend into the right margin, and there is no column separation at all.
- frame
- Same as box (GNU tbl only).
- linesize(n)
- Set lines or rules (e.g. from box) in n-point type.
- nokeep
- Don't use diversions to prevent page breaks (GNU tbl only). Normally tbl attempts to prevent undesirable breaks in boxed tables by using diversions. This can sometimes interact badly with macro packages' own use of diversions, when footnotes, for example, are used.
- nospaces
- Ignore leading and trailing spaces in data items (GNU tbl only).
- nowarn
- Turn off warnings related to tables exceeding the current line width (GNU tbl only).
- tab(x)
- Use the character x instead of a tab to separate items in a line of input data.
Table format specification
After global options come lines describing the format of each line of the table. Each such format line describes one line of the table itself, except that the last format line (which you must end with a period) describes all remaining lines of the table. A single-key character describes each column of each line of the table. Key characters can be separated by spaces or tabs. You may run format specifications for multiple lines together on the same line by separating them with commas.- a,A
- Center longest line in this column and then left-justifies all other lines in this column with respect to that centered line. The idea is to use such alphabetic subcolumns (hence the name of the key character) in combination with L; they are called subcolumns because A items are indented by 1n relative to L entries. Example:
-
.TS
tab(;);
ln,an.
item one;1
subitem two;2
subitem three;3
.T&
ln,an.
item eleven;11
subitem twentytwo;22
subitem thirtythree;33
.TE
- Result:
-
item one 1 subitem two 2 subitem three 3 item eleven 11 subitem twentytwo 22 subitem thirtythree 33
- c,C
- Center item within the column.
- l,L
- Left-justify item within the column.
- n,N
- Numerically justify item in the column: Units positions of numbers are aligned vertically. If there is one or more dots adjacent to a digit, use the rightmost one for vertical alignment. If there is no dot, use the rightmost digit for vertical alignment; otherwise, center the item within the column. Alignment can be forced to a certain position using `\&'; if there is one or more instances of this special (non-printing) character present within the data, use the leftmost one for alignment. Example:
-
.TS
n.
1
1.5
1.5.3
abcde
a\&bcde
.TE
- Result:
-
1 1.5 1.5.3 abcde abcde
- If numerical entries are combined with L or R entries – this can happen if the table format is changed with .T& –, center the widest number (of the data entered under the N specifier regime) relative to the widest L or R entry, preserving the alignment of all numerical entries. Contrary to A type entries, there is no extra indentation.
- Using equations (to be processed with eqn) within columns which use the N specifier is problematic in most cases due to tbl's algorithm for finding the vertical alignment, as described above. Using the global delim option, however, it is possible to make tbl ignore the data within eqn delimiters for that purpose.
- r,R
- Right-justify item within the column.
- s,S
- Span previous item on the left into this column. Not allowed for the first column.
- ^
- Span down entry from previous row in this column. Not allowed for the first row.
- _,-
- Replace this entry with a horizontal line. Note that `_' and `-' can be used for table fields only, not for column separator lines.
- =
- Replace this entry with a double horizontal line. Note that `=' can be used for table fields only, not for column separator lines.
- |
- The corresponding column becomes a vertical rule (if two of these are adjacent, a double vertical rule).
Column specifiers
Here are the specifiers that can appear in suffixes to column key letters (in any order):- b,B
- Short form of fB (make affected entries bold).
- d,D
- Start an item that vertically spans rows, using the `^' column specifier or `\^' data item, at the bottom of its range rather than vertically centering it (GNU tbl only). Example:
-
.TS
tab(;) allbox;
l l
l ld
r ^
l rd.
0000;foobar
T{
1111
.br
2222
T};foo
r;
T{
3333
.br
4444
T};bar
\^;\^
.TE
- Result:
-
0000 foobar 1111 2222 foo r 3333 4444 bar
- e,E
- Make equally-spaced columns. All columns marked with this specifier get the same width; this happens after the affected column widths have been computed (this means that the largest width value rules).
- f,F
- Either of these specifiers may be followed by a font name (either one or two characters long), font number (a single digit), or long name in parentheses (the last form is a GNU tbl extension). A one-letter font name must be separated by one or more blanks from whatever follows.
- i,I
- Short form of fI (make affected entries italic).
- m,M
- This is a GNU tbl extension. Either of these specifiers may be followed by a macro name (either one or two characters long), or long name in parentheses. A one-letter macro name must be separated by one or more blanks from whatever follows. The macro which name can be specified here must be defined before creating the table. It is called just before the table's cell text is output. As implemented currently, this macro is only called if block input is used, that is, text between `T{' and `T}'. The macro should contain only simple troff requests to change the text block formatting, like text adjustment, hyphenation, size, or font. The macro is called after other cell modifications like b, f or v are output. Thus the macro can overwrite other modification specifiers.
- p,P
- Followed by a number, this does a point size change for the affected fields. If signed, the current point size is incremented or decremented (using a signed number instead of a signed digit is a GNU tbl extension). A point size specifier followed by a column separation number must be separated by one or more blanks.
- t,T
- Start an item vertically spanning rows at the top of its range rather than vertically centering it.
- u,U
- Move the corresponding column up one half-line.
- v,V
- Followed by a number, this indicates the vertical line spacing to be used in a multi-line table entry. If signed, the current vertical line spacing is incremented or decremented (using a signed number instead of a signed digit is a GNU tbl extension). A vertical line spacing specifier followed by a column separation number must be separated by one or more blanks. No effect if the corresponding table entry isn't a text block.
- w,W
- Minimum column width value. Must be followed either by a troff(1) width expression in parentheses or a unitless integer. If no unit is given, en units are used. Also used as the default line length for included text blocks. If used multiple times to specify the width for a particular column, the last entry takes effect.
- x,X
- An expanded column. After computing all column widths without an x specifier, use the remaining line width for this column. If there is more than one expanded column, distribute the remaining horizontal space evenly among the affected columns (this is a GNU extension). This feature has the same effect as specifying a minimum column width.
- z,Z
- Ignore the corresponding column for width-calculation purposes, this is, don't use the fields but only the specifiers of this column to compute its width.
Table data
The format lines are followed by lines containing the actual data for the table, followed finally by .TE. Within such data lines, items are normally separated by tab characters (or the character specified with the tab option). Long input lines can be broken across multiple lines if the last character on the line is `\' (which vanishes after concatenation).-
.TS
c,l.
\s[20]MM
MMMM
.TE
-
.TS
cp20,lp20.
MM
MMMM
.TE
-
.TS
c,l.
\s[20]MM
\s[20]MMMM
.TE
Text blocks
A text block can be used to enter data as a single entry which would be too long as a simple string between tabs. It is started with `T{' and closed with `T}'. The former must end a line, and the latter must start a line, probably followed by other data columns (separated with tabs or the character given with the tab global option).Miscellaneous
The number register \n[TW] holds the table width; it can't be used within the table itself but is defined right before calling .TE so that this macro can make use of it.INTERACTION WITH EQN
tbl(1) should always be called before eqn(1) (groff(1) automatically takes care of the correct order of preprocessors).GNU TBL ENHANCEMENTS
There is no limit on the number of columns in a table, nor any limit on the number of text blocks. All the lines of a table are considered in deciding column widths, not just the first 200. Table continuation (.T&) lines are not restricted to the first 200 lines.GNU TBL WITHIN MACROS
Since tbl defines its own macros (right before each table) it is necessary to use an `end-of-macro' macro. Additionally, the escape character has to be switched off. Here an example.-
.eo
.de ATABLE ..
.TS
allbox tab(;);
cl.
\$1;\$2
.TE
...
.ec
.ATABLE A table
.ATABLE Another table
.ATABLE And "another one"
BUGS
You should use .TS H/.TH in conjunction with a supporting macro package for all multi-page boxed tables. If there is no header that you wish to appear at the top of each page of the table, place the .TH line immediately after the format section. Do not enclose a multi-page table within keep/release macros, or divert it in any other way.-
.de BP
. ie '\\n(.z'' .bp \\$1
. el \!.BP \\$1
..
-
.ds a \a
.TS
tab(;);
lw(1i) l.
A\*a;B
.TE
-
|l r|.
-
.TS
tab(#);
|l r|.
left column#right column
.TE
-
.TS
tab(#);
r0|l r0|l.
#left column#right column#
.TE
REFERENCE
Lesk, M.E.: "TBL – A Program to Format Tables". For copyright reasons it cannot be included in the groff distribution, but copies can be found with a title search on the World Wide Web.SEE ALSO
groff(1), troff(1)30 December 2012 | Groff Version 1.22.1 |