.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 and .CR HTML tags: The contents of .CR .TH is horizontally and vertically centered and typeset in boldface. . .IP .RS .XB predecessor: .TR .TD .TH .ETB "cell contents" .XB successor: .TD .TH .TR .ETB "cell contents" .XB arguments: . .RS .XAA colspan= m The width of this cell is the sum of the widths of the\~\c .CI m cells above and below this row. . .XAA rowspan= m The height of this cell is the sum of the heights of the .CI m cells left and right of this column. . .IP .B Remark: Overlapping of column and row spanning, as in the following table fragment (the overlapping happens in the second cell in the second row), is invalid and causes incorrect results. . . .RS .IP .EX \&.TR .TD 1*1 \[dq].TD 1*2 rowspan=2\[dq] .TD 1*3 \&.TR \[dq].TD 2*1 colspan=2\[dq] .TD 2*3 .EE .RE . . .PP A working example for headers and cells with .B colspan is . . .PP .RS .EX \&.TBL cols=3 \&.\& TR \[dq].TH colspan=2\[dq] header1+2 .TH header3 \&.\& TR .TD 1*1 .TD 1*2 .TD 1*3 \&.\& TR .TD 2*1 \[dq].TD colspan=2\[dq] 2*2+3 \&.ETB .EE .RE . . .PP This looks like . . .PP .if t .ne 7v .RS .EX .tr -\- +------------------------------+---------------+ | header1+2 | header3 | +--------------+---------------+---------------+ | 1*1 | 1*2 | 1*3 | +--------------+---------------+---------------+ | 2*1 | 2*2+3 | +--------------+-------------------------------+ .tr -- .EE .RE . . .PP A working example with .B rowspan is . . .PP .RS .EX \&.TBL cols=3 \&.\& TR \&.\& TD 1*1 \&.\& TD rowspan=2 1+2*2 \&.\& TD 1*3 \&.\& \&.\& TR \&.\& TD 2*1 \&.\& TD 2*3 \&.ETB .EE .RE . . .PP which looks like . . .PP .if t .ne 5v .RS .EX .tr -\- +--------------+---------------+---------------+ | 1*1 | 1+2*2 | 1*3 | +--------------+ +---------------+ | 2*1 | | 2*3 | +--------------+---------------+---------------+ .tr -- .EE .RE .RE .RE . .\"================================================================== . . .TP .CB ".ETB \[lB]hold\[rB]" End of the table. . .IP This macro finishes a table. . It causes one of the following actions. . .RS .IP \[bu] 3 If the argument .CR \[oq]hold\[cq] is given, the table is held until it is freed by calling the macro .CR .t*free\c , which in turn prints the table immediately, either at the current position or at the top of the next page if its height is larger than the remaining space on the page. . .IP \[bu] 3 Otherwise, if the table is higher than the remaining space on the page, it is printed at the top of the next page. . .IP \[bu] 3 If neither of the two above constraints hold, the table is printed immediately at the place of its definition. .RE . .IP .RS .XB predecessor: .TD .TH .ETB "cell contents" .XB successor: .TBL .TR .TD .TH .ETB "cell contents" .XB arguments: . .RS .XAA hold Prevent the table from being printed until it is freed by calling the macro .CR .t*free\c \&. . This argument is ignored for inner (nested) tables. .RE .RE . .\"================================================================== . .TP .CBI ".t*free " \[lB]n\[rB] Free the next held table or .CI n\~\c .RI held "" tables. . Call this utility macro to print tables which are held by using the .CR \[oq]hold\[cq] argument of the .CR .ETB macro. . . .\" ==================================================================== .SS "Arguments common to \f[CB].TBL\f[], \f[CB].TR\f[], \f[CB].TD\f[], \ and \f[CB].TH\f[]" .\" ==================================================================== . The arguments described in this section can be specified with the .CR .TBL and .CR .TR macros, but they are eventually passed on to the table cells. . If omitted, the defaults take place, which the user can change by setting the corresponding default registers or strings, as documented below. . Setting an argument with the .CR .TBL macro has the same effect as setting it for all rows in the table. . Setting an argument with a .CR .TR macro has the same effect as setting it for all the .CR .TH or .CR .TD macro in this row. . .IP .XAA bgc= \[lB]c\[rB] The background color of the table cells. . This includes the area specified with the .CR \[oq]csp\[cq] argument. . The argument .CR \[oq]bgc=\[cq] (no value) suppresses a background color; this makes the background transparent. . .XDEFS bgc=bisque t*bgc . .XAA fgc= c The foreground color of the cell contents. . .XDEFS fgc=red4 t*fgc . .XAA ff= name The font family for the table. . .CI name is a .I groff font family identifier, such as .CR A for Avant Garde or .CR HN for Helvetica Narrow. . .XDEF The font family found before the table (string .CR \[oq]t*ff\[cq]\c ). . .XAA fst= style The font style for the table. . One of .CR R\c , .CR B\c , .CR I\c , or .CR BI for roman, .BR bold , .IR italic , or \f[BI]bold italic\f[], \" \f[BI] is not portable man(7) respectively. . As with .IR roff 's .B .ft request, the .CR \[oq]fst\[cq] argument can be used to specify the font family and font style together, for example .CR \[oq]fst=HNBI\[cq] instead of .CR \[oq]ff=HN\[cq] and .CR \[oq]fst=BI\[cq]\c \&. . .XDEF The font style in use right before the table (string .CR \[oq]t*fst\[cq]\c ). . .XAA "fsz=\[aq]" "d1 \[lB]d2\[rB]" \[aq] A decimal or fractional factor .CI d1\c .RI , "" by which the point size for the table is changed, and .CI d2\c .RI , "" by which the vertical line spacing is changed. . If .CI d2 is omitted, value .CI d1 is taken for both. . .XDEFS "fsz=\[aq]1.0 1.0\[aq]" t*fsz . .XAA hal=l\[or]c\[or]b\[or]r Horizontal alignment of the cell contents in the table. . .CR \[oq]hal=l\[cq]\c : left alignment. . .CR \[oq]hal=c\[cq]\c : centered alignment. . .CR \[oq]hal=b\[cq]\c : both (left and right) alignment. . .CR \[oq]hal=r\[cq]\c : right alignment. . .XDEFS hal=b t*hal . .XAA val=t\[or]m\[or]b Vertical alignment of the cell contents in the table for cells lower than the current row. . .CR \[oq]val=t\[cq]\c : alignment below the top of the cell. . .CR \[oq]val=m\[cq]\c : alignment in the middle of the cell. . .CR \[oq]val=b\[cq]\c : alignment above the cell bottom. . .XDEFS val=t t*val . .XAA hl=\[lB]s\[or]d\[rB] Horizontal line between the rows. . If specified with .CR .TD or .CR .TH this is a separator line to the cell below. . .CR \[oq]hl=\[cq] (no value): no separator line. . .CR \[oq]hl=s\[cq]\c : a single separator line between the rows. . .CR \[oq]hl=d\[cq]\c : a double separator line. . .IP The thickness of the separator lines is the half of the border thickness, but at least 0.1\~inches. . The distance between the double lines is equal to the line thickness. . .IP .B Remark: Together with .CR \[oq]border=0\[cq] for proper formatting the value of .CR \[oq]csp\[cq] must be at least \&.05\~inches for single separator lines and \&.15\~inches for double separator lines. . .XDEFS hl=s t*hl . .XAA vl=\[lB]s\[or]d\[rB] Vertical separator line between the cells. . If specified with .CR .TD or .CR .TH this is a separator line to the cell on the right. . .CR \[oq]vl=s\[cq]\c : a single separator line between the cells. . .CR \[oq]vl=d\[cq]\c : a double separator line. . .CR \[oq]vl=\[cq] (no value): no vertical cell separator lines. . For more information see the documentation of the .CR \[oq]hl\[cq] argument above. . .XDEFS vl=s t*vl . . .\" ==================================================================== .SH "\f[I]hdtbl\f[] customization" .\" ==================================================================== . .PP Before creating the first table, you should configure default values to minimize the markup needed in each table. . The following example sets up defaults suitable for typical papers: . . .PP .RS .EX \&.ds t*bgc white\[rs]\[dq] background color \&.ds t*fgc black\[rs]\[dq] foreground color \&.ds t*bc black\[rs]\[dq] border color \&.nr t*cpd 0.1n\[rs]\[dq] cell padding .EE .RE . . .PP The file .I /usr/\:\%share/\:\%doc/\:\%groff\-base/\:\%examples/\:hdtbl/\:\%common\:.roff provides another example setup in the \[lq]minimal Page setup\[rq] section. . . .PP A table which does not fit on a partially filled page is printed automatically on the top of the next page if you append the little utility macro .CR t*hm to the page header macro of your document's main macro package. . For example, say . . .PP .RS .EX \&.am pg@top \&.\& t*hm \&.. .EE .RE . . .PP if you use the .I ms macro package. . . .PP The macro .CR t*EM checks for held or kept tables, and for missing .CR ETB macros (table not closed). . You can call this macro by appending it the to end-of-input macro of the main, or \[lq]full-service\[rq], macro package your document uses. . For example, try . . .RS .EX \&.am pg@end\-text \&.\& t*EM \&.. .EE .RE . if you use the .I ms package. . . .\" ==================================================================== .SH "Bugs and suggestions" .\" ==================================================================== . Please send your comments to the .MT groff@\:gnu\:.org .I groff mailing list .ME or directly to the author. . . .\" ==================================================================== .SH Authors .\" ==================================================================== . The .I hdtbl macro package was written by .MT Joachim\:.Walsdorff@\:urz\:.uni\-heidelberg\:.de Joachim Walsdorff .ME . . . .\" ==================================================================== .SH "See also" .\" ==================================================================== . .TP .MR groff 1 provides an overview of GNU .I roff and details how to invoke .I groff at the command line. . . .TP .MR groff 7 summarizes the .I roff language and GNU extensions to it. . . .TP .MR \%tbl 1 describes the traditional .I roff preprocessor for tables. . . .\" Unwind (some of) the stuff we've done. .rchar \[lB] .rchar \[rB] .rchar \[or] .rchar \[ell] .rchar \[oq] .rchar \[cq] . .\" Restore compatibility mode (for, e.g., Solaris 10/11). .cp \n[*groff_groff_hdtbl_7_man_C] .do rr *groff_groff_hdtbl_7_man_C . . .\" Local Variables: .\" fill-column: 72 .\" mode: nroff .\" End: .\" vim: set filetype=groff textwidth=72: