xref: /freebsd/contrib/mandoc/tbl.7 (revision f4f33ea0c752ff0f9bfad34991d5bbb54e71133d)
1.\"	$Id: tbl.7,v 1.29 2017/10/17 23:19:12 schwarze Exp $
2.\"
3.\" Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4.\" Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: October 17 2017 $
19.Dt TBL 7
20.Os
21.Sh NAME
22.Nm tbl
23.Nd tbl language reference for mandoc
24.Sh DESCRIPTION
25The
26.Nm tbl
27language formats tables.
28It is used within
29.Xr mdoc 7
30and
31.Xr man 7
32pages.
33This manual describes the subset of the
34.Nm
35language accepted by the
36.Xr mandoc 1
37utility.
38.Pp
39Each table is started with a
40.Xr roff 7
41.Ic \&TS
42macro, consist of at most one line of
43.Sx Options ,
44one or more
45.Sx Layout
46lines, one or more
47.Sx Data
48lines, and ends with a
49.Ic \&TE
50macro.
51All input must be 7-bit ASCII.
52.Ss Options
53If the first input line of a table ends with a semicolon, it contains
54case-insensitive options separated by spaces, tabs, or commas.
55Otherwise, it is interpreted as the first
56.Sx Layout
57line.
58.Pp
59The following options are available.
60Some of them require arguments enclosed in parentheses:
61.Bl -tag -width Ds
62.It Cm allbox
63Draw a single-line box around each table cell.
64.It Cm box
65Draw a single-line box around the table.
66For GNU compatibility, this may also be invoked with
67.Cm frame .
68.It Cm center
69Center the table instead of left-adjusting it.
70For GNU compatibility, this may also be invoked with
71.Cm centre .
72.It Cm decimalpoint
73Use the single-character argument as the decimal point with the
74.Cm n
75layout key.
76This is a GNU extension.
77.It Cm delim
78Use the two characters of the argument as
79.Xr eqn 7
80delimiters.
81Currently unsupported.
82.It Cm doublebox
83Draw a double-line box around the table.
84For GNU compatibility, this may also be invoked with
85.Cm doubleframe .
86.It Cm expand
87Increase the width of the table to the current line length.
88Currently ignored.
89.It Cm linesize
90Draw lines with the point size given by the unsigned integer argument.
91Currently ignored.
92.It Cm nokeep
93Allow page breaks within the table.
94This is a GNU extension and currently ignored.
95.It Cm nospaces
96Ignore leading and trailing spaces in data cells.
97This is a GNU extension and currently ignored.
98.It Cm nowarn
99Suppress warnings about tables exceeding the current line length.
100This is a GNU extension and currently ignored.
101.It Cm tab
102Use the single-character argument as a delimiter between data cells.
103By default, the horizontal tabulator character is used.
104.El
105.Ss Layout
106The table layout follows an
107.Sx Options
108line or a
109.Xr roff 7
110.Ic \&TS
111or
112.Ic \&T&
113macro.
114Each layout line specifies how one line of
115.Sx Data
116is formatted.
117The last layout line ends with a full stop.
118It also applies to all remaining data lines.
119Multiple layout lines can be joined by commas on a single physical
120input line.
121.Pp
122Each layout line consists of one or more layout cell specifications,
123optionally separated by whitespace.
124The following case-insensitive key characters start a new cell
125specification:
126.Bl -tag -width 2n
127.It Cm c
128Center the string in this cell.
129.It Cm r
130Right-justify the string in this cell.
131.It Cm l
132Left-justify the string in this cell.
133.It Cm n
134Justify a number around its last decimal point.
135If no decimal point is found in the number,
136it is assumed to trail the number.
137.It Cm s
138Horizontally span columns from the last
139.Pf non- Cm s
140layout cell.
141It is an error if a column span follows a
142.Cm _
143or
144.Cm =
145cell, or comes first on a layout line.
146The combined cell as a whole consumes only one cell
147of the corresponding data line.
148.It Cm a
149Left-justify a string and pad with one space.
150.It Cm ^
151Vertically span rows from the last
152.Pf non- Cm ^
153layout cell.
154It is an error to invoke a vertical span on the first layout line.
155Unlike a horizontal span, a vertical span consumes a data cell
156and discards the content.
157.It Cm _
158Draw a single horizontal line in this cell.
159This consumes a data cell and discards the content.
160It may also be invoked with
161.Cm \- .
162.It Cm =
163Draw a double horizontal line in this cell.
164This consumes a data cell and discards the content.
165.El
166.Pp
167Each cell key may be followed by zero or more of the following
168case-insensitive modifiers:
169.Bl -tag -width 2n
170.It Cm b
171Use a bold font for the contents of this cell.
172.It Cm d
173Move content down to the last row of this vertical span.
174Currently ignored.
175.It Cm e
176Make this column wider to match the maximum width
177of any other column also having the
178.Cm e
179modifier.
180.It Cm f
181The next character selects the font to use for this cell.
182See the
183.Xr roff 7
184manual for supported one-character font names.
185.It Cm i
186Use an italic font for the contents of this cell.
187.It Cm m
188Specify a cell start macro.
189This is a GNU extension and currently unsupported.
190.It Cm p
191Set the point size to the following unsigned argument,
192or change it by the following signed argument.
193Currently ignored.
194.It Cm v
195Set the vertical line spacing to the following unsigned argument,
196or change it by the following signed argument.
197Currently ignored.
198.It Cm t
199Do not vertically center content in this vertical span,
200leave it in the top row.
201Currently ignored.
202.It Cm u
203Move cell content up by half a table row.
204Currently ignored.
205.It Cm w
206Specify a minimum column width.
207.It Cm x
208After determining the width of all other columns, distribute the
209rest of the line length among all columns having the
210.Cm x
211modifier.
212.It Cm z
213Do not use this cell for determining the width of this column.
214.It Cm \&|
215Draw a single vertical line to the right of this cell.
216.It Cm ||
217Draw a double vertical line to the right of this cell.
218.El
219.Pp
220If a modifier consists of decimal digits,
221it specifies a minimum spacing in units of
222.Cm n
223between this column and the next column to the right.
224The default is 3.
225If there is a vertical line, it is drawn inside the spacing.
226.Ss Data
227The data section follows the last
228.Sx Layout
229line.
230Each data line consists of one or more data cells, delimited by
231.Cm tab
232characters.
233.Pp
234If a data cells contains only the single character
235.Ql _
236or
237.Ql = ,
238a single or double horizontal line is drawn across the cell,
239joining its neighbours.
240If a data cells contains only the two character sequence
241.Ql \e_
242or
243.Ql \e= ,
244a single or double horizontal line is drawn inside the cell,
245not joining its neighbours.
246If a data line contains nothing but the single character
247.Ql _
248or
249.Ql = ,
250a horizontal line across the whole table is inserted
251without consuming a layout row.
252.Pp
253In place of any data cell, a text block can be used.
254It starts with
255.Ic \&T{
256at the end of a physical input line.
257Input line breaks inside the text block
258neither end the text block nor its data cell.
259It only ends if
260.Ic \&T}
261occurs at the beginning of a physical input line and is followed
262by an end-of-cell indicator.
263If the
264.Ic \&T}
265is followed by the end of the physical input line, the text block,
266the data cell, and the data line ends at this point.
267If the
268.Ic \&T}
269is followed by the
270.Cm tab
271character, only the text block and the data cell end,
272but the data line continues with the data cell following the
273.Cm tab
274character.
275If
276.Ic \&T}
277is followed by any other character, it does not end the text block,
278which instead continues to the following physical input line.
279.Sh EXAMPLES
280String justification and font selection:
281.Bd -literal -offset indent
282\&.TS
283rb c  lb
284r  ci l.
285r	center	l
286ri	ce	le
287right	c	left
288\&.TE
289.Ed
290.Bd -filled -offset indent
291.TS
292rb c  lb
293r  ci l.
294r	center	l
295ri	ce	le
296right	c	left
297.TE
298.Ed
299.Pp
300Some ports in
301.Ox 6.1
302to show number alignment and line drawing:
303.Bd -literal -offset indent
304\&.TS
305box tab(:);
306r| l
307r  n.
308software:version
309_
310AFL:2.39b
311Mutt:1.8.0
312Ruby:1.8.7.374
313TeX Live:2015
314\&.TE
315.Ed
316.Bd -filled -offset indent
317.TS
318box tab(:);
319r| l
320r  n.
321software:version
322_
323AFL:2.39b
324Mutt:1.8.0
325Ruby:1.8.7.374
326TeX Live:2015
327.TE
328.Ed
329.sp 2v
330Spans and skipping width calculations:
331.Bd -literal -offset indent
332\&.TS
333box tab(:);
334lz  s | rt
335lt| cb| ^
336^ | rz  s.
337left:r
338l:center:
339:right
340\&.TE
341.Ed
342.Bd -filled -offset indent
343.TS
344box tab(:);
345lz  s | rt
346lt| cb| ^
347^ | rz  s.
348left:r
349l:center:
350:right
351.TE
352.Ed
353.sp 2v
354Text blocks, specifying spacings and specifying and equalizing
355column widths, putting lines into individual cells, and overriding
356.Cm allbox :
357.Bd -literal -offset indent
358\&.TS
359allbox tab(:);
360le le||7 lw10.
361The fourth line:_:line 1
362of this column:=:line 2
363determines:\_:line 3
364the column width.:T{
365This text is too wide to fit into a column of width 17.
366T}:line 4
367T{
368No break here.
369T}::line 5
370\&.TE
371.Ed
372.Bd -filled -offset indent
373.TS
374allbox tab(:);
375le le||7 lw10.
376The fourth line:_:line 1
377of this column:=:line 2
378determines:\_:line 3
379the column width.:T{
380This text is too wide to fit into a column of width 17.
381T}:line 4
382T{
383No break here.
384T}::line 5
385.TE
386.Ed
387.sp 2v
388These examples were constructed to demonstrate many
389.Nm
390features in a compact way.
391In real manual pages, keep tables as simple as possible:
392Like that, they usually look better, are less fragile, and more portable.
393.Sh COMPATIBILITY
394The
395.Xr mandoc 1
396implementation of
397.Nm
398doesn't support
399.Xr mdoc 7
400and
401.Xr man 7
402macros and
403.Xr eqn 7
404equations inside tables.
405.Sh SEE ALSO
406.Xr mandoc 1 ,
407.Xr man 7 ,
408.Xr mandoc_char 7 ,
409.Xr mdoc 7 ,
410.Xr roff 7
411.Rs
412.%A M. E. Lesk
413.%T Tbl\(emA Program to Format Tables
414.%D June 11, 1976
415.Re
416.Sh HISTORY
417The tbl utility, a preprocessor for troff, was originally written by M.
418E. Lesk at Bell Labs in 1975.
419The GNU reimplementation of tbl, part of the groff package, was released
420in 1990 by James Clark.
421A standalone tbl implementation was written by Kristaps Dzonsons in
4222010.
423This formed the basis of the implementation that first appeared in
424.Ox 4.9
425as a part of the
426.Xr mandoc 1
427utility.
428.Sh AUTHORS
429This
430.Nm
431reference was written by
432.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
433and
434.An Ingo Schwarze Aq Mt schwarze@openbsd.org .
435