tmac.tbl: use \D'l ..' to draw table borders
[neatroff_make.git] / tmac / tmac.tbl
blobc1af6bbb39e39b0b412545ddc4c5b7747197e112
1 .\" A macro package for simple tables
2 .\"
3 .\" This package creates simple tables, without using the tbl
4 .\" preprocessor.  The main macros are as follows:
5 .\"
6 .\" .tblbeg colwid1 colwid2 ...
7 .\"   This macro begins a table.  Its arguments are the widths of the
8 .\"   columns.  At most four columns are supported.  The width of the
9 .\"   last column can be 0 to expand it to the end of the line.
10 .\"
11 .\" .tblbox all row col
12 .\"   Specifies whether to draw box around the table (when all is 1),
13 .\"   between the rows (when row is 1), or between its columns (when
14 .\"   col is 1).
15 .\"
16 .\" .tblrow "column #1" "column #2" ...
17 .\"   The compact way of specifying the contents of a table row (instead
18 .\"   of calling .tblcol for every column).
19 .\"
20 .\" .tblcol col
21 .\"   Begins column number col for the current row.  With an argument of
22 .\"   1, a new row is inserted.
23 .\"
24 .\" .tblmac mac1 mac2 ...
25 .\"   Before writing the contents of each column, the corresponding
26 .\"   macro in the list of the arguments of this macro is invoked (e.g.,
27 .\"   mac2 is called when starting column #2).
28 .\"
29 .\" .tblrst
30 .\"   This macro is called just before switching to new rows and columns
31 .\"   and drawing the table.  It should reset the indentation (and other
32 .\"   variables such as fonts, if necessary).
33 .\"
34 .\" .tblend
35 .\"   Ends a table.
36 .\"
37 .nr tblgap 1n
38 .nr tblboxall 0
39 .nr tblboxrow 0
40 .nr tblboxcol 0
41 .de tblrst
42 .       in 0
44 .de tblbeg
45 .       tblrst
46 .       nr tblwid1 0\\$1
47 .       if "\\$1"0" .nr tblwid1 \\n(.l
48 .       nr tblwid2 0\\$2
49 .       if "\\$2"0" .nr tblwid2 \\n(.l-\\n[tblwid1]
50 .       nr tblwid3 0\\$3
51 .       if "\\$3"0" .nr tblwid3 \\n(.l-\\n[tblwid1]-\\n[tblwid2]
52 .       nr tblwid4 0\\$4
53 .       if "\\$4"0" .nr tblwid4 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]
54 .       nr tblwid \\n[tblwid1]+\\n[tblwid2]+\\n[tblwid3]+\\n[tblwid4]
55 .       nr tblrow.one 1
57 .de tblmac
58 .       ds tblrst1 "\\$1
59 .       ds tblrst2 "\\$2
60 .       ds tblrst3 "\\$3
61 .       ds tblrst4 "\\$4
63 .de tblbox
64 .       nr tblboxall 0\\$1
65 .       nr tblboxrow 0\\$2
66 .       nr tblboxcol 0\\$3
68 .de tblcolbeg
69 .       nr tblcol.ok 1
70 .       sp |\\n[tblrow.top]u
71 .       tblrst
72 .       \\*[tblrst\\$1]
73 .       if \\$1=1 .in +0u
74 .       if \\$1=2 .in +\\n[tblwid1]u
75 .       if \\$1=3 .in +\\n[tblwid1]u+\\n[tblwid2]u
76 .       if \\$1=4 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u
77 .       ll \\n(.iu+\\n[tblwid\\$1]u
78 .       in +\\n[tblgap]u
79 .       ll -\\n[tblgap]u
81 .de tblcolend
82 .       nr tblcol.ok 0
83 .       if \\n(.d>\\n[tblrow.bot] .nr tblrow.bot \\n(.d
85 .de tblrowbeg
86 .       tblrst
87 .       if (\\n[tblboxall]+\\n[tblboxrow])&(\\n[tblrow.one]) \D'l \\n[tblwid]u 0'
88 .       br
89 .       nr tblrow.ok 1
90 .       nr tblrow.one 0
91 .       mk tblrow.top
92 .       mk tblrow.bot
94 .de tblrowend
95 .       nr tblrow.ok 0
96 .       tblrst
97 .       sp |\\n[tblrow.bot]u
98 .       nr tblht \\n[tblrow.bot]u-\\n[tblrow.top]u+.5v
99 .       sp -.5v
100 .       if \\n[tblboxall]:\\n[tblboxcol] \{\
101 \h'|0'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
102 \h'|\\n[tblwid]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
103 .               sp -1
104 .       \}
105 .       if \\n[tblboxcol] \{\
106 \h'|\\n[tblwid1]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
107 \h'|\\n[tblwid1]u+\\n[tblwid2]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
108 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
109 .               sp -1
110 .       \}
111 .       if \\n[tblboxrow]:(\\n[tblboxall]&\\$1) \{\
112 \h'|0'\D'l \\n[tblwid]u 0'
113 .               sp -1
114 .       \}
115 .       sp
117 .de tblcol
118 .       br
119 .       if \\n[tblcol.ok] .tblcolend \\$1
120 .       if \\$1=1 .if \\n[tblrow.ok] .tblrowend 0
121 .       if \\$1=1 .tblrowbeg
122 .       tblcolbeg \\$1
124 .de tblrow
125 .       if \\n(.$>=1 .tblcol 1
126 .       if \\n(.$>=1 \\$1
127 .       if \\n(.$>=2 .tblcol 2
128 .       if \\n(.$>=2 \\$2
129 .       if \\n(.$>=3 .tblcol 3
130 .       if \\n(.$>=3 \\$3
131 .       if \\n(.$>=4 .tblcol 4
132 .       if \\n(.$>=4 \\$4
134 .de tblend
135 .       br
136 .       if \\n[tblcol.ok] .tblcolend
137 .       if \\n[tblrow.ok] .tblrowend 1
138 .       tblrst