.TH groff_hdtbl 7 "16 October 2023" "groff 1.23.0" .SH Name groff_hdtbl \- Heidelberger table macros for GNU .I roff . . .\" ==================================================================== .\" Legal Terms .\" ==================================================================== .\" .\" Copyright (C) 2005-2020 Free Software Foundation, Inc. .\" .\" This file is part of groff, the GNU roff type-setting system. .\" .\" Permission is granted to copy, distribute and/or modify this .\" document under the terms of the GNU Free Documentation License, .\" Version 1.3 or any later version published by the Free Software .\" Foundation; with no Invariant Sections, with no Front-Cover Texts, .\" and with no Back-Cover Texts. .\" .\" A copy of the Free Documentation License is included as a file .\" called FDL in the main directory of the groff source package. .\" .\" A copy of the GNU Free Documentation License is also available in this .\" Debian package as /usr/share/doc/groff/copyright. . . .\" Save and disable compatibility mode (for, e.g., Solaris 10/11). .do nr *groff_groff_hdtbl_7_man_C \n[.cp] .cp 0 . .\" Define fallback for groff 1.23's MR macro if the system lacks it. .nr do-fallback 0 .if !\n(.f .nr do-fallback 1 \" mandoc .if \n(.g .if !d MR .nr do-fallback 1 \" older groff .if !\n(.g .nr do-fallback 1 \" non-groff *roff .if \n[do-fallback] \{\ . de MR . ie \\n(.$=1 \ . I \%\\$1 . el \ . IR \%\\$1 (\\$2)\\$3 . . .\} .rr do-fallback . . .ig Some simple formatting macros. Note that we use '.ig' here and not a comment to make 'mandb' 2.4.1 (and probably more recent versions also) happy; otherwise the '.char' lines and the stuff which follows is included in the 'whatis' database. .. . . .char \[lB] \F[\n[.fam]]\f[R][ .char \[rB] \F[\n[.fam]]\f[R]] . .char \[or] \F[\n[.fam]]\f[R]\||\| .char \[ell] \F[\n[.fam]]\f[R].\|.\|. . .char \[oq] \F[\n[.fam]]\f[R]\[oq] .char \[cq] \F[\n[.fam]]\f[R]\[cq] . . .ie F CR \{\ . . \" We have to solve the following problem. In this code . \" . \" foo . \" .CR bar . \" foo . \" . \" the space immediately after 'bar' should not be taken from the 'C' . \" family. At the same time, this . \" . \" foo . \" .CR bar\c . \" foo . \" . \" should work also. To fulfill both constraints we emit the . \" family changing commands both as escapes and macro calls. . . de make-C-macro . de C\\$1 . ds old-fam \\\\n[.fam] . fam C . \\$2 \&\\\\$*\F[]\F[\\\\*[old-fam]] . fam . rm old-fam \\.. . . . . make-C-macro R nop . make-C-macro B B . make-C-macro I I . . de make-C-macro . de C\\$1 . ds old-fam \\\\n[.fam] . fam C . \\$1 \\\\$@ \F[]\F[\\\\*[old-fam]] . fam . rm old-fam \\.. . . . . make-C-macro BI . make-C-macro IB . make-C-macro RI . make-C-macro IR . make-C-macro BR . make-C-macro RB .\} .el \{\ . ftr CR R . ftr CI I . ftr CB B . ftr CBI BI . . de CR . nop \&\\$* . . . als CB B . als CI I . . als CBI BI . als CIB IB . als CRI RI . als CIR IR . als CBR BR . als CRB RB .\} . . . .de XB . B "\\$1" . shift . CR "\\$1\c" . shift . while \\n[.$] \{\ . nop , . CR "\\$1\c" . shift . \} . br .. . . .de XAA . TQ . ie (\\n[.$] < 2) \ . CR \\$@ . el \ . CRI \\$@ .. . . .de XDEF . br . B Default: . if !\\n[.$] \ . return . CRI "\\$1" "\\$2" .. . . .de XDEFR . br . B Default: . CR "\[oq]\\$1\[cq]" . nop (register . CR "\[oq]\\$2\[cq]\c" . nop ). .. . . .de XDEFS . br . B Default: . CR "\[oq]\\$1\[cq]" . nop (string . CR "\[oq]\\$2\[cq]\c" . nop ). .. . .\" ==================================================================== .SH Description .\" ==================================================================== . The .I hdtbl macros consist of four base and three optional macros, controlled by about twenty arguments. . The syntax is simple and similar to the HTML table model and nearly as flexible: you can write sequences of tokens (macro calls with their arguments and content data), separated by blanks and beginning with a macro call, into the same line to get compact and cleanly arrranged input. . An advantage of .I hdtbl is that the tables are constructed without calling a preprocessor; this means that .MR groff 7 's full macro capabilities are available. . On the other hand, table processing with .I hdtbl is much slower than using the .MR \%tbl 1 preprocessor. . A further advantage is that the HTML-like syntax of .I hdtbl will be easily converted to HTML; this is not implemented yet. . . .\" ==================================================================== .SH Usage .\" ==================================================================== . In this and the next section, we present examples to help users understand the basic workflow of .IR hdtbl . . First of all, you must load the .I hdtbl.tmac file. . As with nearly all other .I groff macro packages, there are two possibilities to do so: . Either add the line . . .PP .RS .EX \&.mso hdtbl.tmac .EE .RE . . .PP to your .I roff file before using any macros of the .I hdtbl package, or add the option . .PP .RS .EX \-m hdtbl .EE .RE . . .PP to the command line of groff (before the document file which contains .I hdtbl macros). . Then you can include on or more tables in your document, where each one must be started and ended with the .CR .TBL and .CR .ETB macros, respectively. . . .PP In this man page, we approximate the result of each example as terminal output to be as generic as possible since .I hdtbl currently only supports the .B ps and .B pdf output drivers. . . .PP The simplest well-formed table consists of just single calls to the four base table macros in the right order. . Here we construct a table with only one cell. . . .PP .RS .EX \&.TBL \&.TR \&.TD .I contents of the table cell \&.ETB .EE .RE . . .PP A terminal representation is . . .PP .if t .ne 3v .RS .EX .tr -\- +------------------------------------------------------+ .\" That's 27 spaces below. .RI "| " contents-of-the-table-cell " |" +------------------------------------------------------+ .tr -- .EE .RE . . .PP Equivalent to the above is the following notation. . . .PP .RS .EX .RI ".TBL .TR .TD \[dq]" "contents of the table cell" "\[dq] .ETB" .EE .RE . . .PP By default, the formatted table is inserted into the surrounding text at the place of its definition. . If the vertical space isn't sufficient, it is placed at the top of the next page. . Tables can also be stored for later insertion. . . .PP Using .CIR \[oq]row-number * column-number\[cq] as the data for the table cells, a table with two rows and two columns can be written as . . .PP .RS .EX \&.TBL cols=2 \&.\& TR .TD 1*1 .TD 1*2 \&.\& TR .TD 2*1 .TD 2*2 \&.ETB .EE .RE . . .PP A terminal representation is . . .PP .if t .ne 5v .RS .EX .tr -\- +--------------------------+---------------------------+ | 1*1 | 1*2 | +--------------------------+---------------------------+ | 2*1 | 2*2 | +--------------------------+---------------------------+ .tr -- .EE .RE . . .PP Here we see a difference from HTML tables: The number of columns must be explicitly specified using the .CRI \[oq]cols= m\[cq] argument (or indirectly via the .CR \[oq]width\[cq] argument, see below). . . .PP The contents of a table cell is arbitrary; for example, it can be another table, without restriction to the nesting depth. . A given table layout can be either constructed with suitably nested tables or with proper arguments to .CR .TD and .CR .TH\c , controlling column and row spanning. . Note, however, that this table . . .PP .RS .EX \&.TBL \&.\& TR \&.\& TD \&.\& nop 1*1 1*2 \&.\& TR \&.\& TD \&.\& TBL cols=2 border= \&.\& TR \&.\& TD \&.\& nop 2*1 \&.\& TD \&.\& nop 2*2 \&.\& ETB \&.ETB .EE .RE . . .PP and this table . . .PP .RS .EX \&.TBL cols=2 \&.\& TR \&.\& TD colspan=2 \&.\& nop 1*1 1*2 \&.\& TR \&.\& TD \&.\& nop 2*1 \&.\& TD \&.\& nop 2*2 \&.ETB .EE .RE . . .PP are similar but not identical (the use of .CR .nop is purely cosmetic to get proper indentation). . . .PP The first table looks like . .PP .if t .ne 7v .RS .EX .tr -\- +------------------------------------------------------+ | 1*1 1*2 | +------------------------------------------------------+ | | | 2*1 2*2 | | | +------------------------------------------------------+ .tr -- .EE .RE . . .PP and the second one like . . .PP .if t .ne 5v .RS .EX .tr -\- +------------------------------------------------------+ | 1*1 1*2 | +---------------------------+--------------------------+ | 2*1 | 2*2 | +---------------------------+--------------------------+ .tr -- .EE .RE . . .PP Here is the latter table in a more compact form. . .PP .RS .EX \&.TBL cols=2 .TR \[dq].TD colspan=2\[dq] 1*1 1*2 \&.\& TR .TD 2*1 .TD 2*2 .ETB .EE .RE . . .PP If a macro has one or more arguments (see below), and it is not starting a line, everything belonging to this macro including the macro itself must be enclosed in double quotes. . . .\" ==================================================================== .SH "Macros and arguments" .\" ==================================================================== . The order of macro calls and other tokens follows the HTML model. . In the following list, valid predecessors and successors of all .I hdtbl macros are given, together with the possible arguments. . .PP Macro arguments are separated by blanks. . The order of arguments is arbitrary; they are of the form . .PP .RS .CRI key= value .RE . .PP or . .PP .RS .CRI key=\[aq] "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[aq] .RE . .PP with the only exception of the optional argument of the macro .CR .ETB\c , which is the string .CR \[oq]hold\[cq]\c \&. . Another possible form is . .PP .RS .CRI \[dq]key= "value1 \[lB]value2 \[lB]\[ell]\[rB]\[rB]" \[dq] .RE . . .PP However, this is limited to the case where the macro is the first one in the line and not already enclosed in double quotes. . . .PP Argument values specified below as\~\c .CI c are colors predefined by .I groff or colors defined by the user with the .CR .defcolor request. . Argument values\~\c .CI d are decimal numbers with or without decimal point. . Argument values\~\c .CI m are natural numbers. . Argument values\~\c .CI n are numerical values with the usual .I groff scaling indicators. . Some of the arguments are specific to one or two macros, but most of them can be specified with .CR .TBL\c , .CR .TR\c , .CR .TD\c , and .CR .TH\ \&. . These common arguments are explained in the next subsection. . . .PP Most of the argument default values can be changed by the user by setting corresponding default registers or strings, as listed below. . .\"================================================================== . .TP .CBI ".TBL " \[lB]args\[rB] Begin a new table. . .IP .RS .XB predecessor: .TD .TH .ETB "cell contents" .XB successor: .CPTN .TR .XB arguments: . .RS .XAA border= \[lB]n\[rB] Thickness of the surrounding box border. . .CR \%\[oq]border=\[cq] (no value) means neither a surrounding box border nor any horizontal or vertical separator lines between the table rows and cells. . .CR \%\[oq]border=0\[cq] suppresses the surrounding box border, but still allows separator lines between cells and rows. . .XDEFR border=.1n t*b . .XAA bc= c Border color. . .XDEFS bc=red4 t*bc . .XAA cols= m Number of table columns. . This argument is necessary if more than one column is in the table and no .CR \[oq]width\[cq] arguments are present. . .XDEFR cols=1 t*cols . .XAA cpd= n Cell padding, i.e., the extra space between the cell space border and the cell contents. . .XDEFR cpd=.5n t*cpd . .XAA csp= n Cell spacing, i.e., the extra space between the table border or vertical or horizontal lines between cells and the cellspace. . .XDEFR csp=.5n t*csp . .XAA tal=l\[or]c\[or]r Horizontal alignment of the table, if it is smaller than the line width. . .CR \[oq]tal=l\[cq]\c : left alignment. . .CR \[oq]tal=c\[cq]\c : centered alignment. . .CR \[oq]tal=r\[cq]\c : right alignment. . .XDEFR tal=l t*tal . .XAA "width=\[aq]" "w1 \[lB]w2 \[lB]\[ell]\[rB]\[rB]" \[aq] Widths of table cells. . .CI w1\c .RI , "" .CI w2\c .RI , "" \[ell] are either numbers of type\~\c .CI n or natural numbers with the pseudo-scaling indicator .CR \[oq]%\[cq]\c , with the meaning \[lq]percent of the actual line length (or column length for inner tables, respectively)\[rq]. . If there are less width values than table columns, the last width value is used for the remaining cells. . The argument . .RS .IP .CR width=\[aq]1.5i 10%\[aq] .RE . .IP for example indicates that the first column is 1.5\~inches wide; the remaining columns take 1/10 of the column length each. . .XDEF The table width equals the outer line length or column length; the columns have equal widths. . .XAA height= n Height of the table. . If the table with its contents is lower than\~\c .CI n\c .RI , "" the last row is stretched to this value. .RE .RE . .\"================================================================== . .TP .CBI ".CPTN " \[lB]args\[rB] Text of caption. . .IP The (optionally numbered) table caption. . .CR .CPTN is optional. . .IP .RS .XB predecessor: .TBL .XB successor: .TR .XB arguments: . .RS .XAA val=t\[or]b Vertical alignment of the table caption. . .CR \[oq]val=t\[cq]\c : The caption is placed above the table. . .CR \[oq]val=b\[cq]\c : The caption is placed below the table. . .XDEFS val=t t*cptn .RE .RE . .\"================================================================== . .TP .CBI ".TR " \[lB]args\[rB] Begin a new table row. . .IP .RS .XB predecessor: .TBL .CPTN .TD .TH .ETB "cell contents" .XB successor: .TD .TH .XB arguments: . .RS .XAA height= n The height of the row. . If a cell in the row is higher than\~\c .CI n\c .RI , "" this value is ignored; otherwise the row height is stretched to\~\c .CI n\c .RI . "" .RE .RE . .\"================================================================== . .TP .CBI ".TD " "\[lB]args \[lB]cell contents\[rB]\[rB]" Begin a table data cell. .TQ .CBI ".TH " "\[lB]args \[lB]cell contents\[rB]\[rB]" Begin a table header cell. . .IP Arguments and cell contents can be mixed. . The macro .CR .TH is not really necessary and differs from .CR .TD only in three default settings, similar to the .CR