1TBL(7)               BSD Miscellaneous Information Manual               TBL(7)
2

NAME

4     tbl — tbl language reference for mandoc
5

DESCRIPTION

7     The tbl language formats tables.  It is used within mdoc(7) and man(7)
8     pages.  This manual describes the subset of the tbl language accepted by
9     the mandoc(1) utility.
10
11     Each table is started with a roff(7) TS macro, consist of at most one
12     line of Options, one or more Layout lines, one or more Data lines, and
13     ends with a TE macro.  All input must be 7-bit ASCII.
14
15   Options
16     If the first input line of a table ends with a semicolon, it contains
17     case-insensitive options separated by spaces, tabs, or commas.  Other‐
18     wise, it is interpreted as the first Layout line.
19
20     The following options are available.  Some of them require arguments en‐
21     closed in parentheses:
22
23     allbox  Draw a single-line box around each table cell.
24
25     box     Draw a single-line box around the table.  For GNU compatibility,
26             this may also be invoked with frame.
27
28     center  Center the table instead of left-adjusting it.  For GNU compati‐
29             bility, this may also be invoked with centre.
30
31     decimalpoint
32             Use the single-character argument as the decimal point with the n
33             layout key.  This is a GNU extension.
34
35     delim   Use the two characters of the argument as eqn(7) delimiters.
36             Currently unsupported.
37
38     doublebox
39             Draw a double-line box around the table.  For GNU compatibility,
40             this may also be invoked with doubleframe.
41
42     expand  Increase the width of the table to the current line length.  Cur‐
43             rently ignored.
44
45     linesize
46             Draw lines with the point size given by the unsigned integer ar‐
47             gument.  Currently ignored.
48
49     nokeep  Allow page breaks within the table.  This is a GNU extension and
50             currently ignored.
51
52     nospaces
53             Ignore leading and trailing spaces in data cells.  This is a GNU
54             extension.
55
56     nowarn  Suppress warnings about tables exceeding the current line length.
57             This is a GNU extension and currently ignored.
58
59     tab     Use the single-character argument as a delimiter between data
60             cells.  By default, the horizontal tabulator character is used.
61
62   Layout
63     The table layout follows an Options line or a roff(7) TS or T& macro.
64     Each layout line specifies how one line of Data is formatted.  The last
65     layout line ends with a full stop.  It also applies to all remaining data
66     lines.  Multiple layout lines can be joined by commas on a single physi‐
67     cal input line.
68
69     Each layout line consists of one or more layout cell specifications, op‐
70     tionally separated by whitespace.  The following case-insensitive key
71     characters start a new cell specification:
72
73     c   Center the string in this cell.
74
75     r   Right-justify the string in this cell.
76
77     l   Left-justify the string in this cell.
78
79     n   Justify a number around its last decimal point.  If no decimal point
80         is found in the number, it is assumed to trail the number.
81
82     s   Horizontally span columns from the last non-s layout cell.  It is an
83         error if a column span follows a _ or = cell, or comes first on a
84         layout line.  The combined cell as a whole consumes only one cell of
85         the corresponding data line.
86
87     a   Left-justify a string and pad with one space.
88
89     ^   Vertically span rows from the last non-^ layout cell.  It is an error
90         to invoke a vertical span on the first layout line.  Unlike a hori‐
91         zontal span, a vertical span consumes a data cell and discards the
92         content.
93
94     _   Draw a single horizontal line in this cell.  This consumes a data
95         cell and discards the content.  It may also be invoked with -.
96
97     =   Draw a double horizontal line in this cell.  This consumes a data
98         cell and discards the content.
99
100     Each cell key may be followed by zero or more of the following case-in‐
101     sensitive modifiers:
102
103     b   Use a bold font for the contents of this cell.
104
105     d   Move content down to the last row of this vertical span.  Currently
106         ignored.
107
108     e   Make this column wider to match the maximum width of any other column
109         also having the e modifier.
110
111     f   The next one or two characters select the font to use for this cell.
112         One-character font names must be followed by a blank or period.  See
113         the roff(7) manual for supported font names.
114
115     i   Use an italic font for the contents of this cell.
116
117     m   Specify a cell start macro.  This is a GNU extension and currently
118         unsupported.
119
120     p   Set the point size to the following unsigned argument, or change it
121         by the following signed argument.  Currently ignored.
122
123     v   Set the vertical line spacing to the following unsigned argument, or
124         change it by the following signed argument.  Currently ignored.
125
126     t   Do not vertically center content in this vertical span, leave it in
127         the top row.  Currently ignored.
128
129     u   Move cell content up by half a table row.  Currently ignored.
130
131     w   Specify a minimum column width.
132
133     x   After determining the width of all other columns, distribute the rest
134         of the line length among all columns having the x modifier.
135
136     z   Do not use this cell for determining the width of this column.
137
138     |   Draw a single vertical line to the right of this cell.
139
140     ||  Draw a double vertical line to the right of this cell.
141
142     If a modifier consists of decimal digits, it specifies a minimum spacing
143     in units of n between this column and the next column to the right.  The
144     default is 3.  If there is a vertical line, it is drawn inside the spac‐
145     ing.
146
147   Data
148     The data section follows the last Layout line.  Each data line consists
149     of one or more data cells, delimited by tab characters.
150
151     If a data cell contains only the two bytes ‘\^’, the cell above spans to
152     this row, as if the layout specification of this cell were ^.
153
154     If a data cell contains only the single character ‘_’ or ‘=’, a single or
155     double horizontal line is drawn across the cell, joining its neighbours.
156     If a data cell contains only the two character sequence ‘\_’ or ‘\=’, a
157     single or double horizontal line is drawn inside the cell, not joining
158     its neighbours.  If a data line contains nothing but the single character
159     ‘_’ or ‘=’, a horizontal line across the whole table is inserted without
160     consuming a layout row.
161
162     In place of any data cell, a text block can be used.  It starts with T{
163     at the end of a physical input line.  Input line breaks inside the text
164     block neither end the text block nor its data cell.  It only ends if T}
165     occurs at the beginning of a physical input line and is followed by an
166     end-of-cell indicator.  If the T} is followed by the end of the physical
167     input line, the text block, the data cell, and the data line ends at this
168     point.  If the T} is followed by the tab character, only the text block
169     and the data cell end, but the data line continues with the data cell
170     following the tab character.  If T} is followed by any other character,
171     it does not end the text block, which instead continues to the following
172     physical input line.
173

EXAMPLES

175     String justification and font selection:
176
177           .TS
178           rb c  lb
179           r  ci l.
180           r       center  l
181           ri      ce      le
182           right   c       left
183           .TE
184
185               r   center   l
186              ri     ce     le
187           right     c      left
188
189     Some ports in OpenBSD 6.1 to show number alignment and line drawing:
190
191           .TS
192           box tab(:);
193           r| l
194           r  n.
195           software:version
196           _
197           AFL:2.39b
198           Mutt:1.8.0
199           Ruby:1.8.7.374
200           TeX Live:2015
201           .TE
202
203           ┌─────────┬───────────┐
204           │software │ version   │
205           ├─────────┴───────────┤
206           │     AFL       2.39b │
207           │    Mutt     1.8.0   │
208           │    Ruby   1.8.7.374 │
209           │TeX Live    2015     │
210           └─────────────────────┘
211
212     Spans and skipping width calculations:
213
214           .TS
215           box tab(:);
216           lz  s | rt
217           lt| cb| ^
218           ^ | rz  s.
219           left:r
220           l:center:
221           :right
222           .TE
223
224           ┌───────────┬───┐
225           │le│ft       │ r │
226           │l │ center │   │
227           │  │      right │
228           └──┴────────────┘
229
230     Text blocks, specifying spacings and specifying and equalizing column
231     widths, putting lines into individual cells, and overriding allbox:
232
233           .TS
234           allbox tab(:);
235           le le||7 lw10.
236           The fourth line:_:line 1
237           of this column:=:line 2
238           determines:_:line 3
239           the column width.:T{
240           This text is too wide to fit into a column of width 17.
241           T}:line 4
242           T{
243           No break here.
244           T}::line 5
245           .TE
246
247           ┌────────────────────┬───────────────────────┬┬─────────────┐
248           │The fourth line     ├───────────────────────┤│  line 1     │
249           ├────────────────────┼───────────────────────┼┼─────────────┤
250           │of this column      ├───────────────────────┤│  line 2     │
251           ├────────────────────┼───────────────────────┼┼─────────────┤
252           │determines          │ ────────────────────  ││  line 3     │
253           ├────────────────────┼───────────────────────┼┼─────────────┤
254           │the column width.   │ This  text  is  too   ││  line 4     │
255           │                    │ wide  to fit into a   ││             │
256           │                    │ column of width 17.   ││             │
257           ├────────────────────┼───────────────────────┼┼─────────────┤
258           │No break here.      │                       ││  line 5     │
259           └────────────────────┴───────────────────────┴┴─────────────┘
260
261     These examples were constructed to demonstrate many tbl features in a
262     compact way.  In real manual pages, keep tables as simple as possible.
263     They usually look better, are less fragile, and are more portable.
264

COMPATIBILITY

266     The mandoc(1) implementation of tbl doesn't support mdoc(7) and man(7)
267     macros and eqn(7) equations inside tables.
268

SEE ALSO

270     mandoc(1), man(7), mandoc_char(7), mdoc(7), roff(7)
271
272     M. E. Lesk, Tbl  A Program to Format Tables, June 11, 1976.
273

HISTORY

275     The tbl utility, a preprocessor for troff, was originally written by M.
276     E. Lesk at Bell Labs in 1975.  The GNU reimplementation of tbl, part of
277     the groff package, was released in 1990 by James Clark.  A standalone tbl
278     implementation was written by Kristaps Dzonsons in 2010.  This formed the
279     basis of the implementation that first appeared in OpenBSD 4.9 as a part
280     of the mandoc(1) utility.
281

AUTHORS

283     This tbl reference was written by Kristaps Dzonsons <kristaps@bsd.lv> and
284     Ingo Schwarze <schwarze@openbsd.org>.
285

BUGS

287     In -T utf8 output mode, heavy lines are drawn instead of double lines.
288     This cannot be improved because the Unicode standard only provides an in‐
289     complete set of box drawing characters with double lines, whereas it pro‐
290     vides a full set of box drawing characters with heavy lines.  It is un‐
291     likely this can be improved in the future because the box drawing charac‐
292     ters are already marked in Unicode as characters intended only for back‐
293     ward compatibility with legacy systems, and their use is not encouraged.
294     So it seems unlikely that the missing ones might get added in the future.
295
296BSD                           September 18, 2021                           BSD
Impressum