1TBL(1)                      General Commands Manual                     TBL(1)
2
3
4

NAME

6       tbl - format tables for troff
7

SYNOPSIS

9       tbl [-Cv] [files ...]
10

DESCRIPTION

12       This manual page describes the GNU version of tbl, which is part of the
13       groff document formatting system.  tbl compiles descriptions of  tables
14       embedded  within troff input files into commands that are understood by
15       troff.  Normally, it should be invoked using the -t  option  of  groff.
16       It is highly compatible with Unix tbl.  The output generated by GNU tbl
17       cannot be processed with Unix troff; it  must  be  processed  with  GNU
18       troff.  If no files are given on the command line or a filename of - is
19       given, the standard input is read.
20

OPTIONS

22       -C     Enable compatibility mode to recognize .TS  and  .TE  even  when
23              followed  by  a  character  other than space or newline.  Leader
24              characters (\a) are handled as interpreted.
25
26       -v     Print the version number.
27

USAGE

29       tbl expects to find table descriptions wrapped in the .TS (table start)
30       and .TE (table end) macros.
31
32   Global options
33       The  line  immediately  following  the .TS macro may contain any of the
34       following global options (ignoring the case of characters  –  Unix  tbl
35       only  accepts  options  with all characters lowercase or all characters
36       uppercase), separated by spaces, tabs, or commas:
37
38       allbox Enclose each item of the table in a box.
39
40       box    Enclose the table in a box.
41
42       center Center the table (default is left-justified).   The  alternative
43              keyword name centre is also recognized (this is a GNU tbl exten‐
44              sion).
45
46       decimalpoint(c)
47              Set the character to be  recognized  as  the  decimal  point  in
48              numeric columns (GNU tbl only).
49
50       delim(xy)
51              Use x and y as start and end delimiters for eqn(1).
52
53       doublebox
54              Enclose the table in a double box.
55
56       doubleframe
57              Same as doublebox (GNU tbl only).
58
59       expand Make  the  table as wide as the current line length (providing a
60              column separation factor).  Ignored if one or  more  `x'  column
61              specifiers are used (see below).
62
63              In  case the sum of the column widths is larger than the current
64              line length, the column separation factor is set to  zero;  such
65              tables extend into the right margin, and there is no column sep‐
66              aration at all.
67
68       frame  Same as box (GNU tbl only).
69
70       linesize(n)
71              Set lines or rules (e.g. from box) in n-point type.
72
73       nokeep Don't use diversions to prevent  page  breaks  (GNU  tbl  only).
74              Normally  tbl  attempts  to  prevent undesirable breaks in boxed
75              tables by using diversions.  This can sometimes  interact  badly
76              with  macro packages' own use of diversions, when footnotes, for
77              example, are used.
78
79       nospaces
80              Ignore leading and trailing spaces in data items (GNU tbl only).
81
82       nowarn Turn off warnings related to tables exceeding the  current  line
83              width (GNU tbl only).
84
85       tab(x) Use the character x instead of a tab to separate items in a line
86              of input data.
87
88       The global options must end with a semicolon.  There  might  be  white‐
89       space between an option and its argument in parentheses.
90
91   Table format specification
92       After  global  options come lines describing the format of each line of
93       the table.  Each such format line  describes  one  line  of  the  table
94       itself,  except  that  the  last format line (which you must end with a
95       period) describes all remaining lines of the table.  A single-key char‐
96       acter  describes each column of each line of the table.  Key characters
97       can be separated by spaces or tabs.  You may run format  specifications
98       for  multiple  lines  together on the same line by separating them with
99       commas.
100
101       You may follow each key character with specifiers  that  determine  the
102       font  and  point  size of the corresponding item, that determine column
103       width, inter-column spacing, etc.
104
105       The longest format line defines the number of  columns  in  the  table;
106       missing  format  descriptors  at the end of format lines are assumed to
107       be L.  Extra columns in the data (which have  no  corresponding  format
108       entry) are ignored.
109
110       The available key characters are:
111
112       a,A    Center  longest  line in this column and then left-justifies all
113              other lines in this column with respect to that  centered  line.
114              The idea is to use such alphabetic subcolumns (hence the name of
115              the key character) in combination with L; they are  called  sub‐
116              columns   because  A  items  are  indented  by  1n  relative  to
117              L entries.  Example:
118
119                     .TS
120                     tab(;);
121                     ln,an.
122                     item one;1
123                     subitem two;2
124                     subitem three;3
125                     .T&
126                     ln,an.
127                     item eleven;11
128                     subitem twentytwo;22
129                     subitem thirtythree;33
130                     .TE
131
132              Result:
133
134                     item one                 1
135                      subitem two             2
136                      subitem three           3
137                     item eleven             11
138                      subitem twentytwo      22
139                      subitem thirtythree    33
140
141       c,C    Center item within the column.
142
143       l,L    Left-justify item within the column.
144
145       n,N    Numerically justify item in the column: Units positions of  num‐
146              bers are aligned vertically.  If there is one or more dots adja‐
147              cent to a digit, use the rightmost one for  vertical  alignment.
148              If  there is no dot, use the rightmost digit for vertical align‐
149              ment; otherwise, center the item within the  column.   Alignment
150              can  be forced to a certain position using `\&'; if there is one
151              or more  instances  of  this  special  (non-printing)  character
152              present  within  the  data,  use the leftmost one for alignment.
153              Example:
154
155                     .TS
156                     n.
157                     1
158                     1.5
159                     1.5.3
160                     abcde
161                     a\&bcde
162                     .TE
163
164              Result:
165
166                       1
167                       1.5
168                     1.5.3
169                      abcde
170                       abcde
171
172              If numerical entries are combined with L or R entries – this can
173              happen  if  the  table  format is changed with .T& –, center the
174              widest number (of the data entered under the N specifier regime)
175              relative to the widest L or R entry, preserving the alignment of
176              all numerical entries.  Contrary to A type entries, there is  no
177              extra indentation.
178
179              Using  equations (to be processed with eqn) within columns which
180              use the N specifier is problematic in most cases  due  to  tbl's
181              algorithm  for  finding  the  vertical  alignment,  as described
182              above.  Using the global delim option, however, it  is  possible
183              to  make tbl ignore the data within eqn delimiters for that pur‐
184              pose.
185
186       r,R    Right-justify item within the column.
187
188       s,S    Span previous item on the left into this  column.   Not  allowed
189              for the first column.
190
191       ^      Span  down  entry from previous row in this column.  Not allowed
192              for the first row.
193
194       _,-    Replace this entry with a horizontal line.  Note  that  `_'  and
195              `-'  can be used for table fields only, not for column separator
196              lines.
197
198       =      Replace this entry with a double horizontal line.  Note that `='
199              can  be  used  for  table  fields only, not for column separator
200              lines.
201
202       |      The corresponding column becomes a  vertical  rule  (if  two  of
203              these are adjacent, a double vertical rule).
204
205       A  vertical  bar to the left of the first key letter or to the right of
206       the last one produces a line at the edge of the table.
207
208       To change the data format within a table, use the .T& command  (at  the
209       start  of  a  line).   It  is followed by format and data lines (but no
210       global options) similar to the .TS request.
211
212   Column specifiers
213       Here are the specifiers that can appear in suffixes to column key  let‐
214       ters (in any order):
215
216       b,B    Short form of fB (make affected entries bold).
217
218       d,D    Start  an  item that vertically spans rows, using the `^' column
219              specifier or `\^' data item, at the bottom of its  range  rather
220              than vertically centering it (GNU tbl only).  Example:
221
222                     .TS
223                     tab(;) allbox;
224                     l l
225                     l ld
226                     r ^
227                     l rd.
228                     0000;foobar
229                     T{
230                     1111
231                     .br
232                     2222
233                     T};foo
234                     r;
235                     T{
236                     3333
237                     .br
238                     4444
239                     T};bar
240                     \^;\^
241                     .TE
242
243              Result:
244
245                     ┌─────┬────────┐
246                     │0000 │ foobar │
247                     ├─────┼────────┤
248                     │1111 │        │
249                     │2222 │        │
250                     ├─────┤        │
251                     │   r │ foo    │
252                     ├─────┼────────┤
253                     │3333 │        │
254                     │4444 │    bar │
255                     └─────┴────────┘
256       e,E    Make equally-spaced columns.  All columns marked with this spec‐
257              ifier get the same width; this happens after the affected column
258              widths  have  been  computed  (this means that the largest width
259              value rules).
260
261       f,F    Either of these specifiers  may  be  followed  by  a  font  name
262              (either  one  or  two  characters  long),  font number (a single
263              digit), or long name in parentheses (the last form is a GNU  tbl
264              extension).   A one-letter font name must be separated by one or
265              more blanks from whatever follows.
266
267       i,I    Short form of fI (make affected entries italic).
268
269       m,M    This is a GNU tbl extension.  Either of these specifiers may  be
270              followed by a macro name (either one or two characters long), or
271              long name in parentheses.  A one-letter macro name must be sepa‐
272              rated  by  one  or more blanks from whatever follows.  The macro
273              which name can be specified here must be defined before creating
274              the  table.   It  is called just before the table's cell text is
275              output.  As implemented currently, this macro is only called  if
276              block  input  is used, that is, text between `T{' and `T}'.  The
277              macro should contain only simple troff requests  to  change  the
278              text  block formatting, like text adjustment, hyphenation, size,
279              or font.  The macro is called  after  other  cell  modifications
280              like  b,  f or v are output.  Thus the macro can overwrite other
281              modification specifiers.
282
283       p,P    Followed by a number, this does a  point  size  change  for  the
284              affected  fields.   If  signed, the current point size is incre‐
285              mented or decremented (using a signed number instead of a signed
286              digit  is a GNU tbl extension).  A point size specifier followed
287              by a column separation number must be separated by one  or  more
288              blanks.
289
290       t,T    Start  an  item vertically spanning rows at the top of its range
291              rather than vertically centering it.
292
293       u,U    Move the corresponding column up one half-line.
294
295       v,V    Followed by a number, this indicates the vertical  line  spacing
296              to  be used in a multi-line table entry.  If signed, the current
297              vertical line spacing is incremented  or  decremented  (using  a
298              signed number instead of a signed digit is a GNU tbl extension).
299              A vertical line spacing specifier followed by a  column  separa‐
300              tion  number must be separated by one or more blanks.  No effect
301              if the corresponding table entry isn't a text block.
302
303       w,W    Minimum column width  value.   Must  be  followed  either  by  a
304              troff(1)  width expression in parentheses or a unitless integer.
305              If no unit is given, en  units  are  used.   Also  used  as  the
306              default  line length for included text blocks.  If used multiple
307              times to specify the width for a  particular  column,  the  last
308              entry takes effect.
309
310       x,X    An  expanded  column.  After computing all column widths without
311              an x specifier, use the remaining line width  for  this  column.
312              If  there  is  more  than  one  expanded  column, distribute the
313              remaining horizontal space evenly  among  the  affected  columns
314              (this  is a GNU extension).  This feature has the same effect as
315              specifying a minimum column width.
316
317       z,Z    Ignore the corresponding column for width-calculation  purposes,
318              this  is,  don't  use the fields but only the specifiers of this
319              column to compute its width.
320
321       A number suffix on a key character is interpreted as a  column  separa‐
322       tion in en units (multiplied in proportion if the expand option is on –
323       in case of overfull tables this might be zero).  Default separation  is
324       3n.
325
326       The column specifier x is mutually exclusive with e and w (but e is not
327       mutually exclusive with w); if specified multiple times for a  particu‐
328       lar  column,  the last entry takes effect: x unsets both e and w, while
329       either e or w overrides x.
330
331   Table data
332       The format lines are followed by lines containing the actual  data  for
333       the  table, followed finally by .TE.  Within such data lines, items are
334       normally separated by tab characters (or the character  specified  with
335       the  tab option).  Long input lines can be broken across multiple lines
336       if the last character on the line is `\' (which vanishes after concate‐
337       nation).
338
339       Note  that  tbl computes the column widths line by line, applying \w on
340       each entry which isn't a text block.  As a  consequence,  constructions
341       like
342
343              .TS
344              c,l.
345              \s[20]MM
346              MMMM
347              .TE
348
349       fail; you must either say
350
351              .TS
352              cp20,lp20.
353              MM
354              MMMM
355              .TE
356
357       or
358
359              .TS
360              c,l.
361              \s[20]MM
362              \s[20]MMMM
363              .TE
364
365       A dot starting a line, followed by anything but a digit is handled as a
366       troff command, passed through without changes.  The table  position  is
367       unchanged in this case.
368
369       If  a  data  line consists of only `_' or `=', a single or double line,
370       respectively, is drawn across the table at that point; if a single item
371       in  a data line consists of only `_' or `=', then that item is replaced
372       by a single or double line, joining its neighbours.   If  a  data  item
373       consists  only  of `\_' or `\=', a single or double line, respectively,
374       is drawn across the field at that point which does not join its  neigh‐
375       bours.
376
377       A data item consisting only of `\Rx' (`x' any character) is replaced by
378       repetitions of character `x' as wide as the  column  (not  joining  its
379       neighbours).
380
381       A  data  item  consisting only of `\^' indicates that the field immedi‐
382       ately above spans downward over this row.
383
384   Text blocks
385       A text block can be used to enter data as a single entry which would be
386       too  long as a simple string between tabs.  It is started with `T{' and
387       closed with `T}'.  The former must end a  line,  and  the  latter  must
388       start  a  line, probably followed by other data columns (separated with
389       tabs or the character given with the tab global option).
390
391       By default, the text block is formatted with the  settings  which  were
392       active  before entering the table, possibly overridden by the m, v, and
393       w tbl specifiers.  For example, to make all text  blocks  ragged-right,
394       insert .na right before the starting .TS (and .ad after the table).
395
396       If either `w' or `x' specifiers are not given for all columns of a text
397       block span, the default length of the text block (to be  more  precise,
398       the  line  length used to process the text block diversion) is computed
399       as L×C/(N+1), where `L' is the current line length, `C' the  number  of
400       columns  spanned by the text block, and `N' the total number of columns
401       in the table.  Note,  however,  that  the  actual  diversion  width  as
402       returned in register \n[dl] is used eventually as the text block width.
403       If necessary, you can also control the text block width with  a  direct
404       insertion of a .ll request right after `T{'.
405
406   Miscellaneous
407       The  number  register  \n[TW]  holds  the table width; it can't be used
408       within the table itself but is defined right before calling .TE so that
409       this macro can make use of it.
410
411       tbl  also  defines a macro .T# which produces the bottom and side lines
412       of a boxed table.  While tbl does call this macro itself at the end  of
413       the  table, it can be used by macro packages to create boxes for multi-
414       page tables by calling it within the page footer.  An example  of  this
415       is  shown by the -ms macros which provide this functionality if a table
416       starts with .TS H instead of the standard call to the .TS macro.
417

INTERACTION WITH EQN

419       tbl(1) should always be called before  eqn(1)  (groff(1)  automatically
420       takes care of the correct order of preprocessors).
421

GNU TBL ENHANCEMENTS

423       There is no limit on the number of columns in a table, nor any limit on
424       the number of text blocks.  All the lines of a table are considered  in
425       deciding  column  widths,  not  just the first 200.  Table continuation
426       (.T&) lines are not restricted to the first 200 lines.
427
428       Numeric and alphabetic items may appear in the same column.
429
430       Numeric and alphabetic items may span horizontally.
431
432       tbl uses register, string, macro and diversion names beginning with the
433       digit  3.   When  using  tbl you should avoid using any names beginning
434       with a 3.
435

GNU TBL WITHIN MACROS

437       Since tbl defines its own macros (right before each table) it is neces‐
438       sary  to use an `end-of-macro' macro.  Additionally, the escape charac‐
439       ter has to be switched off.  Here an example.
440
441              .eo
442              .de ATABLE ..
443              .TS
444              allbox tab(;);
445              cl.
446              \$1;\$2
447              .TE
448              ...
449              .ec
450              .ATABLE A table
451              .ATABLE Another table
452              .ATABLE And "another one"
453
454       Note, however, that not all features of tbl can be wrapped into a macro
455       because  tbl  sees  the  input earlier than troff.  For example, number
456       formatting with vertically aligned decimal points fails if  those  num‐
457       bers  are passed on as macro parameters because decimal point alignment
458       is handled by tbl itself: It only sees `\$1', `\$2', etc.,  and  there‐
459       fore can't recognize the decimal point.
460

BUGS

462       You should use .TS H/.TH in conjunction with a supporting macro package
463       for all multi-page boxed tables.  If there is no header that  you  wish
464       to  appear  at  the  top  of each page of the table, place the .TH line
465       immediately after the format section.  Do not enclose a multi-page  ta‐
466       ble within keep/release macros, or divert it in any other way.
467
468       A text block within a table must be able to fit on one page.
469
470       The bp request cannot be used to force a page-break in a multi-page ta‐
471       ble.  Instead, define BP as follows
472
473              .de BP
474              .  ie '\\n(.z'' .bp \\$1
475              .  el \!.BP \\$1
476              ..
477
478       and use BP instead of bp.
479
480       Using \a directly in a table to get leaders does not  work  (except  in
481       compatibility mode).  This is correct behaviour: \a is an uninterpreted
482       leader.  To get leaders use a real leader, either by using a control  A
483       or like this:
484
485              .ds a \a
486              .TS
487              tab(;);
488              lw(1i) l.
489              A\*a;B
490              .TE
491
492       A leading and/or trailing `|' in a format line, such as
493
494              |l r|.
495
496       gives  output which has a 1n space between the resulting bordering ver‐
497       tical rule and the content of the adjacent column, as in
498
499              .TS
500              tab(#);
501              |l r|.
502              left column#right column
503              .TE
504
505       If it is desired to have zero space (so that the rule touches the  con‐
506       tent),  this can be achieved by introducing extra “dummy” columns, with
507       no content and zero separation, before and/or after, as in
508
509              .TS
510              tab(#);
511              r0|l r0|l.
512              #left column#right column#
513              .TE
514
515       The resulting “dummy” columns are invisible and have zero  width;  note
516       that such columns usually don't work with TTY devices.
517

REFERENCE

519       Lesk,  M.E.: "TBL – A Program to Format Tables".  For copyright reasons
520       it cannot be included in the groff  distribution,  but  copies  can  be
521       found with a title search on the World Wide Web.
522

SEE ALSO

524       groff(1), troff(1)
525
526
527
528Groff Version 1.22.2            7 February 2013                         TBL(1)
Impressum