groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / src / preproc / tbl / tbl.man
CommitLineData
4d3e9548 1'\" t
92d0a6a6 2.ig
4d3e9548
JL
3Copyright (C) 1989-1995, 2001, 2002, 2003, 2004, 2006, 2007, 2008,
4 2009
92d0a6a6
JR
5 Free Software Foundation, Inc.
6
7Permission is granted to make and distribute verbatim copies of
8this manual provided the copyright notice and this permission notice
9are preserved on all copies.
10
11Permission is granted to copy and distribute modified versions of this
12manual under the conditions for verbatim copying, provided that the
13entire resulting derived work is distributed under the terms of a
14permission notice identical to this one.
15
16Permission is granted to copy and distribute translations of this
17manual into another language, under the above conditions for modified
18versions, except that this permission notice may be included in
19translations approved by the Free Software Foundation instead of in
20the original English.
21..
4d3e9548
JL
22.
23.
92d0a6a6 24.TH @G@TBL @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
4d3e9548
JL
25.
26.
92d0a6a6
JR
27.SH NAME
28@g@tbl \- format tables for troff
29.
30.
31.SH SYNOPSIS
4d3e9548
JL
32.SY @g@tbl
33.OP \-Cv
34.RI [ files\~ .\|.\|.]
35.YS
92d0a6a6
JR
36.
37.
38.SH DESCRIPTION
39This manual page describes the GNU version of
40.BR tbl ,
41which is part of the groff document formatting system.
42.B tbl
43compiles descriptions of tables embedded within
44.B troff
45input files into commands that are understood by
46.BR troff .
47Normally, it should be invoked using the
48.B \-t
49option of
50.B groff.
51It is highly compatible with Unix
52.BR tbl .
53The output generated by GNU
54.B tbl
55cannot be processed with Unix
56.BR troff ;
57it must be processed with GNU
58.BR troff .
4d3e9548 59If no files are given on the command line or a filename of
92d0a6a6 60.B \-
4d3e9548 61is given, the standard input is read.
92d0a6a6
JR
62.
63.
64.SH OPTIONS
65.TP
66.B \-C
465b256c
JR
67Enable compatibility mode to
68recognize
92d0a6a6
JR
69.B .TS
70and
71.B .TE
72even when followed by a character other than space or newline.
465b256c 73Leader characters (\[rs]a) are handled as interpreted.
4d3e9548 74.
92d0a6a6
JR
75.TP
76.B \-v
77Print the version number.
78.
79.
80.SH USAGE
81.B tbl
82expects to find table descriptions wrapped in the
83.B .TS
84(table start) and
85.B .TE
86(table end) macros.
4d3e9548
JL
87.
88.
89.SS Global options
92d0a6a6
JR
90The line immediately following the
91.B .TS
4d3e9548
JL
92macro may contain any of the following global options (ignoring the case of
93characters \[en] Unix tbl only accepts options with all characters lowercase
94or all characters uppercase), separated by spaces, tabs, or commas:
95.
96.TP
97.B allbox
98Enclose each item of the table in a box.
99.
100.TP
101.B box
102Enclose the table in a box.
92d0a6a6
JR
103.
104.TP
105.B center
4d3e9548 106Center the table (default is left-justified).
92d0a6a6
JR
107The alternative keyword name
108.B centre
109is also recognized (this is a GNU tbl extension).
110.
111.TP
4d3e9548
JL
112.BI decimalpoint( c )
113Set the character to be recognized as the decimal point in numeric
114columns (GNU tbl only).
115.
116.TP
92d0a6a6
JR
117.BI delim( xy )
118Use
119.I x
4d3e9548 120and\~\c
92d0a6a6
JR
121.I y
122as start and end delimiters for
123.BR @g@eqn (@MAN1EXT@).
124.
125.TP
4d3e9548
JL
126.B doublebox
127Enclose the table in a double box.
92d0a6a6
JR
128.
129.TP
4d3e9548
JL
130.B doubleframe
131Same as doublebox (GNU tbl only).
92d0a6a6
JR
132.
133.TP
4d3e9548
JL
134.B expand
135Make the table as wide as the current line length (providing a column
136separation factor).
137Ignored if one or more `x' column specifiers are used (see below).
92d0a6a6 138.
4d3e9548
JL
139.IP
140In case the sum of the column widths is larger than the current line length,
141the column separation factor is set to zero; such tables extend into the
142right margin, and there is no column separation at all.
92d0a6a6
JR
143.
144.TP
145.B frame
146Same as box (GNU tbl only).
147.
148.TP
92d0a6a6 149.BI linesize( n )
4d3e9548 150Set lines or rules (e.g. from
92d0a6a6
JR
151.BR box )
152in
153.IR n -point
154type.
155.
156.TP
157.B nokeep
158Don't use diversions to prevent page breaks (GNU tbl only).
159Normally
160.B tbl
4d3e9548 161attempts to prevent undesirable breaks in boxed tables by using diversions.
92d0a6a6
JR
162This can sometimes interact badly with macro packages' own use of
163diversions, when footnotes, for example, are used.
164.
165.TP
92d0a6a6
JR
166.B nospaces
167Ignore leading and trailing spaces in data items (GNU tbl only).
168.
4d3e9548
JL
169.TP
170.BI tab( x )
171Use the character
172.I x
173instead of a tab to separate items in a line of input data.
174.
92d0a6a6
JR
175.LP
176The global options must end with a semicolon.
4d3e9548
JL
177There might be whitespace between an option and its argument in parentheses.
178.
179.
180.SS Table format specification
92d0a6a6
JR
181After global options come lines describing the format of each line of
182the table.
183Each such format line describes one line of the table itself, except that
184the last format line (which you must end with a period) describes all
185remaining lines of the table.
4d3e9548
JL
186A single-key character describes each column of each line of the table.
187Key characters can be separated by spaces or tabs.
188You may run format specifications for multiple lines together on the same
189line by separating them with commas.
190.
92d0a6a6
JR
191.LP
192You may follow each key character with specifiers that determine the font
193and point size of the corresponding item, that determine column width,
194inter-column spacing, etc.
4d3e9548 195.
92d0a6a6
JR
196.LP
197The longest format line defines the number of columns in the table; missing
4d3e9548
JL
198format descriptors at the end of format lines are assumed to be\~\c
199.BR L .
92d0a6a6
JR
200Extra columns in the data (which have no corresponding format entry) are
201ignored.
4d3e9548 202.
92d0a6a6
JR
203.LP
204The available key characters are:
205.
206.TP
4d3e9548
JL
207.BR a , A
208Center longest line in this column and then left-justifies all other lines
209in this column with respect to that centered line.
210The idea is to use such alphabetic subcolumns (hence the name of the key
211character) in combination with\~
212.BR L ;
213they are called subcolumns because
214.BR A \~items
215are indented by\~1n relative to
216.BR L \~entries.
217Example:
218.RS
219.IP
220.EX
221\&.TS
222\&tab(;);
223\&ln,an.
224\&item one;1
225\&subitem two;2
226\&subitem three;3
227\&.T&
228\&ln,an.
229\&item eleven;11
230\&subitem twentytwo;22
231\&subitem thirtythree;33
232\&.TE
233.EE
234.RE
235.
236.IP
237Result:
238.
239.RS
240.IP
241.TS
242tab(;);
243ln,an.
244item one;1
245subitem two;2
246subitem three;3
247.T&
248ln,an.
249item eleven;11
250subitem twentytwo;22
251subitem thirtythree;33
252.TE
253.RE
92d0a6a6
JR
254.
255.TP
4d3e9548
JL
256.BR c , C
257Center item within the column.
92d0a6a6
JR
258.
259.TP
4d3e9548
JL
260.BR l , L
261Left-justify item within the column.
92d0a6a6
JR
262.
263.TP
4d3e9548
JL
264.BR n , N
265Numerically justify item in the column: Units positions of numbers are
92d0a6a6 266aligned vertically.
4d3e9548
JL
267If there is one or more dots adjacent to a digit, use the rightmost one for
268vertical alignment.
269If there is no dot, use the rightmost digit for vertical alignment;
270otherwise, center the item within the column.
271Alignment can be forced to a certain position using `\[rs]&'; if there is
272one or more instances of this special (non-printing) character present
273within the data, use the leftmost one for alignment.
274Example:
275.RS
276.IP
277.EX
278\&.TS
279\&n.
280\&1
281\&1.5
282\&1.5.3
283\&abcde
284\&a\[rs]&bcde
285\&.TE
286.EE
287.RE
288.
289.IP
290Result:
291.
292.RS
293.IP
294.TS
295n.
2961
2971.5
2981.5.3
299abcde
300a\&bcde
301.TE
302.RE
303.
304.IP
305If numerical entries are combined with
306.B L
307or
308.BR R \~entries
309\[en] this can happen if the table format is changed with
310.B .T&
311\%\[en],
312center the widest
313.I number
314(of the data entered under the
315.BR N \~specifier
316regime) relative to the widest
317.B L
318or
319.BR R \~entry,
320preserving the alignment of all numerical entries.
321Contrary to
322.BR A \~type
323entries, there is no extra indentation.
324.
325.IP
326Using equations (to be processed with
327.BR eqn )
328within columns which use the
329.BR N \~specifier
330is problematic in most cases due to
331.BR tbl 's
332algorithm for finding the vertical alignment, as described above.
333Using the global
334.B delim
335option, however, it is possible to make
336.B tbl
337ignore the data within
338.B eqn
339delimiters for that purpose.
340.
92d0a6a6
JR
341.
342.TP
4d3e9548
JL
343.BR r , R
344Right-justify item within the column.
92d0a6a6
JR
345.
346.TP
4d3e9548
JL
347.BR s , S
348Span previous item on the left into this column.
349Not allowed for the first column.
92d0a6a6
JR
350.
351.TP
4d3e9548
JL
352.B ^
353Span down entry from previous row in this column.
354Not allowed for the first row.
92d0a6a6
JR
355.
356.TP
4d3e9548
JL
357.BR _ , -
358Replace this entry with a horizontal line.
92d0a6a6
JR
359.
360.TP
4d3e9548 361.B =
92d0a6a6 362.
4d3e9548 363Replace this entry with a double horizontal line.
92d0a6a6
JR
364.
365.TP
4d3e9548 366.B |
92d0a6a6
JR
367The corresponding column becomes a vertical rule (if two of these are
368adjacent, a double vertical rule).
369.
370.LP
4d3e9548 371A vertical bar to the left of the first key letter or to the right of the
92d0a6a6 372last one produces a line at the edge of the table.
4d3e9548 373.
92d0a6a6 374.LP
4d3e9548
JL
375To change the data format within a table, use the
376.B .T&
377command (at the start of a line).
378It is followed by format and data lines (but no global options) similar to
379the
380.B .TS
381request.
92d0a6a6 382.
92d0a6a6 383.
4d3e9548
JL
384.SS Column specifiers
385Here are the specifiers that can appear in suffixes to column key letters
386(in any order):
92d0a6a6
JR
387.
388.TP
4d3e9548
JL
389.BR b , B
390Short form of
391.B fB
392(make affected entries bold).
92d0a6a6
JR
393.
394.TP
4d3e9548 395.BR d , D
92d0a6a6
JR
396Start an item vertically spanning rows at the bottom of its range rather
397than vertically centering it (GNU tbl only).
398.
399.TP
4d3e9548
JL
400.BR e , E
401Make equally-spaced columns.
402All columns marked with this specifier get the same width; this happens
403after the affected column widths have been computed (this means that the
404largest width value rules).
92d0a6a6
JR
405.
406.TP
4d3e9548 407.BR f , F
92d0a6a6
JR
408Either of these specifiers may be followed by a font name (either one or two
409characters long), font number (a single digit), or long name in parentheses
410(the last form is a GNU tbl extension).
411A one-letter font name must be separated by one or more blanks from whatever
412follows.
413.
414.TP
4d3e9548
JL
415.BR i , I
416Short form of
417.B fI
418(make affected entries italic).
92d0a6a6
JR
419.
420.TP
4d3e9548 421.BR m , M
92d0a6a6
JR
422This is a GNU tbl extension.
423Either of these specifiers may be followed by a macro name
424(either one or two characters long),
425or long name in parentheses.
426A one-letter macro name must be separated by one or more blanks
427from whatever follows.
428The macro which name can be specified here
429must be defined before creating the table.
430It is called just before the table's cell text is output.
431As implemented currently, this macro is only called if block input is used,
432that is, text between `T{' and `T}'.
433The macro should contain only simple
434.B troff
435requests to change the text block formatting, like text adjustment,
436hyphenation, size, or font.
437The macro is called
438.I after
439other cell modifications like
440.BR b ,
441.B f
442or
443.B v
444are output.
445Thus the macro can overwrite other modification specifiers.
446.
447.TP
4d3e9548
JL
448.BR p , P
449Followed by a number, this does a point size change for the affected fields.
450If signed, the current point size is incremented or decremented (using a
451signed number instead of a signed digit is a GNU tbl extension).
452A point size specifier followed by a column separation number must be
453separated by one or more blanks.
92d0a6a6
JR
454.
455.TP
4d3e9548
JL
456.BR t , T
457Start an item vertically spanning rows at the top of its range rather than
458vertically centering it.
459.
460.TP
461.BR u , U
92d0a6a6
JR
462Move the corresponding column up one half-line.
463.
464.TP
4d3e9548
JL
465.BR v , V
466Followed by a number, this indicates the vertical line spacing to be used in
467a multi-line table entry.
468If signed, the current vertical line spacing is incremented or decremented
469(using a signed number instead of a signed digit is a GNU tbl extension).
470A vertical line spacing specifier followed by a column separation number
471must be separated by one or more blanks.
472No effect if the corresponding table entry isn't a text block.
473.
474.TP
475.BR w , W
476Minimal column width value.
477Must be followed either by a
478.BR @g@troff (@MAN1EXT@)
479width expression in parentheses or a unitless integer.
480If no unit is given, en units are used.
481Also used as the default line length for included text blocks.
482If used multiple times to specify the width for a particular column,
483the last entry takes effect.
484.
485.TP
486.BR x , X
487An expanded column.
488After computing all column widths without an
489.BR x \~specifier,
490use the remaining line width for this column.
491If there is more than one expanded column, distribute the remaining
492horizontal space evenly among the affected columns (this is a GNU
493extension).
494This feature has the same effect as specifying a minimum column width.
495.
496.TP
497.BR z , Z
498Ignore the corresponding column for width-calculation purposes, this is,
499don't use the fields but only the specifiers of this column to compute
500its width.
92d0a6a6
JR
501.
502.LP
503A number suffix on a key character is interpreted as a column
4d3e9548 504separation in en units (multiplied in proportion if the
92d0a6a6 505.B expand
4d3e9548 506option is on \[en] in case of overfull tables this might be zero).
92d0a6a6 507Default separation is 3n.
4d3e9548 508.
92d0a6a6 509.LP
4d3e9548
JL
510The column
511.RB specifier\~ x
512is mutually exclusive with
513.B e
514.RB and\~ w
515(but
516.B e
517is not mutually exclusive
518.RB with\~ w );
519if specified multiple times for a particular column, the last entry takes
520effect:
521.BR x \~unsets
522both
523.B e
524.RB and\~ w ,
525while either
526.B e
527or
528.B w
529.RB overrides\~ x .
530.
531.
532.SS Table data
92d0a6a6
JR
533The format lines are followed by lines containing the actual data for the
534table, followed finally by
535.BR .TE .
536Within such data lines, items are normally separated by tab characters (or
537the character specified with the
538.B tab
539option).
540Long input lines can be broken across multiple lines if the last character
4d3e9548
JL
541on the line is `\[rs]' (which vanishes after concatenation).
542.
543.LP
544Note that
545.B @g@tbl
546computes the column widths line by line, applying \[rs]w on each entry
547which isn't a text block.
548As a consequence, constructions like
549.IP
550.EX
551\&.TS
552\&c,l.
553\&\[rs]s[20]MM
554\&MMMM
555\&.TE
556.EE
557.
558.LP
559fail; you must either say
560.IP
561.EX
562\&.TS
563\&cp20,lp20.
564\&MM
565\&MMMM
566\&.TE
567.EE
568.
569.LP
570or
571.
572.IP
573.EX
574\&.TS
575\&c,l.
576\&\[rs]s[20]MM
577\&\[rs]s[20]MMMM
578\&.TE
579.EE
580.
92d0a6a6
JR
581.LP
582A dot starting a line, followed by anything but a digit is handled as a
583troff command, passed through without changes.
584The table position is unchanged in this case.
4d3e9548 585.
92d0a6a6
JR
586.LP
587If a data line consists of only `_' or `=', a single or double line,
588respectively, is drawn across the table at that point; if a single item in a
589data line consists of only `_' or `=', then that item is replaced by a
590single or double line, joining its neighbours.
4d3e9548 591If a data item consists only of `\[rs]_' or `\[rs]=', a single or double line,
92d0a6a6
JR
592respectively, is drawn across the field at that point which does not join
593its neighbours.
4d3e9548 594.
92d0a6a6 595.LP
4d3e9548 596A data item consisting only of `\[rs]Rx' (`x' any character) is replaced by
92d0a6a6
JR
597repetitions of character `x' as wide as the column (not joining its
598neighbours).
4d3e9548 599.
92d0a6a6 600.LP
4d3e9548 601A data item consisting only of `\[rs]^' indicates that the field immediately
92d0a6a6 602above spans downward over this row.
4d3e9548
JL
603.
604.
605.SS Text blocks
92d0a6a6
JR
606A text block can be used to enter data as a single entry which would be
607too long as a simple string between tabs.
608It is started with `T{' and closed with `T}'.
609The former must end a line, and the latter must start a line, probably
4d3e9548
JL
610followed by other data columns (separated with tabs or the character given
611with the
612.B tab
613global option).
614.
615.LP
92d0a6a6
JR
616By default, the text block is formatted with the settings which were
617active before entering the table, possibly overridden by the
4d3e9548
JL
618.BR m ,
619.BR v ,
92d0a6a6
JR
620and
621.B w
622tbl specifiers.
623For example, to make all text blocks ragged-right, insert
624.B .na
625right before the starting
626.B .TS
627(and
628.B .ad
629after the table).
4d3e9548 630.
92d0a6a6 631.LP
4d3e9548
JL
632If either `w' or `x' specifiers are not given for
633.I all
634columns of a text block span, the default length of the text block (to be
635more precise, the line length used to process the text block diversion) is
636computed as L\[tmu]C/(N+1), where `L' is the current line length, `C' the
637number of columns spanned by the text block, and `N' the total number of
638columns in the table.
639Note, however, that the actual diversion width as returned in register
640.B \[rs]n[dl]
641is used eventually as the text block width.
642If necessary, you can also control the text block width with a direct
643insertion of a
644.B .ll
645request right after `T{'.
646.
647.
648.SS Miscellaneous
649The number register
650.B \[rs]n[TW]
651holds the table width; it can't be used within the table itself but is defined
652right before calling
653.B .TE
654so that this macro can make use of it.
655.
656.LP
657.B tbl
658also defines a macro
659.B .T#
660which produces the bottom and side lines of a boxed table.
661While
662.B tbl
663does call this macro itself at the end of the table, it can be used by
664macro packages to create boxes for multi-page tables by calling it within the
665page footer.
666An example of this is shown by the
667.B \-ms
668macros which provide this functionality if a table starts with
669.B .TS\ H
670instead of the standard call to the
92d0a6a6 671.B .TS
4d3e9548 672macro.
92d0a6a6
JR
673.
674.
675.SH "INTERACTION WITH @G@EQN"
676.BR @g@tbl (@MAN1EXT@)
677should always be called before
678.BR @g@eqn (@MAN1EXT@)
679.RB ( groff (@MAN1EXT@)
680automatically takes care of the correct order of preprocessors).
681.
682.
683.SH "GNU TBL ENHANCEMENTS"
684There is no limit on the number of columns in a table, nor any limit on the
685number of text blocks.
686All the lines of a table are considered in deciding column widths, not just
687the first 200.
688Table continuation
689.RB ( .T& )
690lines are not restricted to the first 200 lines.
4d3e9548 691.
92d0a6a6
JR
692.LP
693Numeric and alphabetic items may appear in the same column.
4d3e9548 694.
92d0a6a6
JR
695.LP
696Numeric and alphabetic items may span horizontally.
4d3e9548 697.
92d0a6a6
JR
698.LP
699.B @g@tbl
700uses register, string, macro and diversion names beginning with the digit\~\c
701.BR 3 .
702When using
703.B @g@tbl
704you should avoid using any names beginning with a\~\c
705.BR 3 .
706.
707.
4d3e9548
JL
708.SH "GNU TBL WITHIN MACROS"
709Since
710.B @g@tbl
711defines its own macros (right before each table) it is necessary to use
712an `end-of-macro' macro. Additionally, the escape character has to be switched
713off. Here an example.
714.IP
715.EX
716\&.eo
717\&.de ATABLE ..
718\&.TS
719\&allbox tab(;);
720\&cl.
721\&\[rs]$1;\[rs]$2
722\&.TE
723\&...
724\&.ec
725\&.ATABLE A table
726\&.ATABLE Another table
727\&.ATABLE And \[dq]another one\[dq]
728.EE
729.
730.LP
731Note, however, that not all features of
732.B @g@tbl
733can be wrapped into a macro because
734.B @g@tbl
735sees the input earlier than
736.BR @g@troff .
737For example, number formatting with vertically aligned decimal points
738fails if those numbers are passed on as macro parameters because
739decimal point alignment is handled by
740.B @g@tbl
741itself: It only sees `\[rs]$1', `\[rs]$2', etc., and therefore can't
742recognize the decimal point.
743.
744.
92d0a6a6
JR
745.SH BUGS
746You should use
747.BR .TS\ H / .TH
748in conjunction with a supporting macro package for
749.I all
750multi-page boxed tables.
751If there is no header that you wish to appear at the top of each page
752of the table, place the
753.B .TH
754line immediately after the format section.
755Do not enclose a multi-page table within keep/release macros,
756or divert it in any other way.
4d3e9548 757.
92d0a6a6
JR
758.LP
759A text block within a table must be able to fit on one page.
4d3e9548 760.
92d0a6a6
JR
761.LP
762The
763.B bp
764request cannot be used to force a page-break in a multi-page table.
765Instead, define
766.B BP
767as follows
4d3e9548 768.
92d0a6a6 769.IP
4d3e9548
JL
770.EX
771\&.de BP
772\&. ie '\[rs]\[rs]n(.z'' .bp \[rs]\[rs]$1
773\&. el \[rs]!.BP \[rs]\[rs]$1
774\&..
775.EE
776.
92d0a6a6
JR
777.LP
778and use
779.B BP
780instead of
781.BR bp .
4d3e9548 782.
92d0a6a6 783.LP
4d3e9548 784Using \[rs]a directly in a table to get leaders does not work (except in
465b256c 785compatibility mode).
4d3e9548 786This is correct behaviour: \[rs]a is an
92d0a6a6
JR
787.B uninterpreted
788leader.
789To get leaders use a real leader, either by using a control A or like
790this:
4d3e9548 791.
92d0a6a6 792.IP
4d3e9548
JL
793.EX
794\&.ds a \[rs]a
92d0a6a6 795\&.TS
4d3e9548
JL
796\&tab(;);
797\&lw(1i) l.
798\&A\[rs]*a;B
92d0a6a6 799\&.TE
4d3e9548 800.EE
92d0a6a6
JR
801.
802.
803.SH REFERENCE
4d3e9548 804Lesk, M.E.: "TBL \[en] A Program to Format Tables".
92d0a6a6
JR
805For copyright reasons it cannot be included in the groff distribution,
806but copies can be found with a title search on the World Wide Web.
807.
808.
809.SH "SEE ALSO"
810.BR groff (@MAN1EXT@),
811.BR @g@troff (@MAN1EXT@)
812.
813.\" Local Variables:
814.\" mode: nroff
815.\" End: