tbl
Format tables for troff or groff
TLDR
Process input with tables, saving the output for future typesetting with groff to PostScript
Typeset input with tables to PDF using the [me] macro package
SYNOPSIS
tbl [options] [file ...]
PARAMETERS
-v
Print the version number.
-s
Separate data columns by tabs instead of spaces (for easier editing).
-i
Interpret tab-separated columns as input instead of formatted output.
-T name
Assume output is for specified terminal device, name. Typically used when tbl would misidentify output.
-ms
Use the ms macro package for table output instead of the default. (Historical)
-mm
Use the mm macro package for table output instead of the default. (Historical)
DESCRIPTION
The tbl command is a preprocessor for the troff typesetting system. It formats tables described in a simple language within a document. It converts the table description into troff commands that will generate the table when the document is processed by troff. The tbl command reads the input file (or standard input if no file is specified), identifies table descriptions delimited by the .TS and .TE macros, and generates troff code to render the table. The table descriptions define the layout, data, and formatting of the table. It handles horizontal and vertical spanning, different alignment options, and number conversion. It's commonly used in conjunction with other troff preprocessors like eqn (equation formatter) and pic (picture drawing tool) to create complex documents.
tbl is an essential tool for generating publication-quality tables within troff documents, especially for technical documentation, scientific reports, and academic papers. Modern alternatives like LaTeX often handle tables more directly, but tbl remains a valuable tool for those working with troff environments.
CAVEATS
tbl uses a fairly rigid syntax, and errors in the table description can lead to unexpected output or even halt processing. It is also primarily used with troff, which itself has a significant learning curve. More modern typesetting systems offer more intuitive table creation tools. It is important to note that the ms and mm macro packages are old styles, so using those flags might give unexpected or undesirable output.
TABLE STRUCTURE
Tables in tbl are defined between .TS (table start) and .TE (table end) macros. Inside these macros, you first specify the format of the table (alignment, line drawing, etc.), then the table data. Data is separated by spaces or tabs (depending on the -s flag) and rows are separated by newlines. Special codes are used to indicate spanning columns or rows.
FORMAT LINE
The format line specifies how each column in the table should be rendered. Common format specifiers include:
L (left-aligned), R (right-aligned), C (centered), N (numeric), S (spanning), A (alphabetic left-aligned). The format line is terminated with a period (.) and must come after the .TS macro but before the table data.
HISTORY
tbl was developed as part of the Unix typesetting toolchain in the early 1970s at Bell Labs. It was designed to simplify the creation of tables within troff documents, which were otherwise difficult to format manually. It has been widely used in Unix environments for decades, and its functionality is now often included as part of larger typesetting systems like groff. Its simplicity and direct integration with troff made it a long-lasting tool for generating technical documentation.