tmac.tbl: support up to seven columns
[neatroff_make.git] / tmac / tmac.tbl
blob27a5a778831e62c827e70740b615726e73900c8f
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 seven 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 .\"   Starts a new row.  Parameters provide a compact way of
18 .\"   specifying  the contents of a table row (instead of calling
19 .\"   .tblcol for every column).
20 .\"
21 .\" .tblcol col
22 .\"   Begins column number col for the current row.
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 .nr tblbrdrsz 30        \" border point size
42 .nr tblvertsz 16        \" vertical line point size
43 .nr tblhorisz 16        \" horizontal line point size
44 .de tblrst
45 .       in 0
47 .de tblbeg
48 .       tblrst
49 .       nr tblwid1 0\\$1
50 .       if "\\$1"0" .nr tblwid1 \\n(.l
51 .       nr tblwid2 0\\$2
52 .       if "\\$2"0" .nr tblwid2 \\n(.l-\\n[tblwid1]
53 .       nr tblwid3 0\\$3
54 .       if "\\$3"0" .nr tblwid3 \\n(.l-\\n[tblwid1]-\\n[tblwid2]
55 .       nr tblwid4 0\\$4
56 .       if "\\$4"0" .nr tblwid4 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]
57 .       nr tblwid5 0\\$5
58 .       if "\\$5"0" .nr tblwid5 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]-\\n[tblwid4]
59 .       nr tblwid6 0\\$6
60 .       if "\\$6"0" .nr tblwid6 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]-\\n[tblwid4]-\\n[tblwid5]
61 .       nr tblwid7 0\\$7
62 .       if "\\$7"0" .nr tblwid7 \\n(.l-\\n[tblwid1]-\\n[tblwid2]-\\n[tblwid3]-\\n[tblwid4]-\\n[tblwid5]-\\n[tblwid6]
63 .       nr tblcnt \\n(.$
64 .       nr tblwid \\n[tblwid1]+\\n[tblwid2]+\\n[tblwid3]+\\n[tblwid4]+\\n[tblwid5]+\\n[tblwid6]+\\n[tblwid7]
65 .       nr tblrow.one 1
67 .de tblmac
68 .       ds tblrst1 "\\$1
69 .       ds tblrst2 "\\$2
70 .       ds tblrst3 "\\$3
71 .       ds tblrst4 "\\$4
72 .       ds tblrst5 "\\$5
73 .       ds tblrst6 "\\$6
74 .       ds tblrst7 "\\$7
76 .de tblbox
77 .       nr tblboxall 0\\$1
78 .       nr tblboxrow 0\\$2
79 .       nr tblboxcol 0\\$3
81 .de tblcolbeg
82 .       nr tblcol.ok 1
83 .       sp |\\n[tblrow.top]u
84 .       tblrst
85 .       \\*[tblrst\\$1]
86 .       if \\$1=1 .in +0u
87 .       if \\$1=2 .in +\\n[tblwid1]u
88 .       if \\$1=3 .in +\\n[tblwid1]u+\\n[tblwid2]u
89 .       if \\$1=4 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u
90 .       if \\$1=5 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u+\\n[tblwid4]u
91 .       if \\$1=6 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u+\\n[tblwid4]u+\\n[tblwid5]u
92 .       if \\$1=7 .in +\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u+\\n[tblwid4]u+\\n[tblwid5]u+\\n[tblwid6]u
93 .       ll \\n(.iu+\\n[tblwid\\$1]u
94 .       in +\\n[tblgap]u
95 .       ll -\\n[tblgap]u
97 .de tblcolend
98 .       br
99 .       nr tblcol.ok 0
100 .       if \\n(.d>\\n[tblrow.bot] .nr tblrow.bot \\n(.d
102 .de tblrowbeg
103 .       tblrst
104 .       if (\\n[tblboxall]+\\n[tblboxrow])&(\\n[tblrow.one]) \s[\\n[tblbrdrsz]]\D'l \\n[tblwid]u 0'\s[]
105 .       br
106 .       nr tblrow.ok 1
107 .       nr tblrow.one 0
108 .       mk tblrow.top
109 .       mk tblrow.bot
111 .de tblrowend
112 .       if \\n[tblcol.ok] .tblcolend \\$1
113 .       nr tblrow.ok 0
114 .       tblrst
115 .       sp |\\n[tblrow.bot]u
116 .       nr tblht \\n[tblrow.bot]u-\\n[tblrow.top]u+.5v
117 .       sp -.5v
118 .       if \\n[tblboxall]:\\n[tblboxcol] \{\
119 .               ps \\n[tblbrdrsz]
120 \h'|0'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
121 \h'|\\n[tblwid]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
122 .               ps
123 .               sp -1
124 .       \}
125 .       if \\n[tblboxcol] \{\
126 .               ps \\n[tblvertsz]
127 \h'|\\n[tblwid1]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
128 \h'|\\n[tblwid1]u+\\n[tblwid2]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
129 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
130 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u+\\n[tblwid4]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
131 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u+\\n[tblwid4]u+\\n[tblwid5]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'\
132 \h'|\\n[tblwid1]u+\\n[tblwid2]u+\\n[tblwid3]u+\\n[tblwid4]u+\\n[tblwid5]u+\\n[tblwid6]u'\D'l 0 -\\n[tblht]u'\v'\\n[tblht]u'
133 .               ps
134 .               sp -1
135 .       \}
136 .       if \\n[tblboxrow]:(\\n[tblboxall]&\\$1) \{\
137 .               ie \\$1 .ps \\n[tblbrdrsz]
138 .               el .ps \\n[tblhorisz]
139 \h'|0'\D'l \\n[tblwid]u 0'
140 .               ps
141 .               sp -1
142 .       \}
143 .       sp
145 .de tblcol
146 .       br
147 .       if \\n[tblcol.ok] .tblcolend \\$1
148 .       tblcolbeg \\$1
149 .       if \\n(.$>=2 \\$2
151 .de tblrow
152 .       if \\n[tblrow.ok] .tblrowend 0
153 .       tblrowbeg
154 .       if \\n(.$>=1 .tblcol 1
155 .       if \\n(.$>=1 \\$1
156 .       if \\n(.$>=2 .tblcol 2
157 .       if \\n(.$>=2 \\$2
158 .       if \\n(.$>=3 .tblcol 3
159 .       if \\n(.$>=3 \\$3
160 .       if \\n(.$>=4 .tblcol 4
161 .       if \\n(.$>=4 \\$4
162 .       if \\n(.$>=5 .tblcol 5
163 .       if \\n(.$>=5 \\$5
164 .       if \\n(.$>=6 .tblcol 6
165 .       if \\n(.$>=6 \\$6
166 .       if \\n(.$>=7 .tblcol 7
167 .       if \\n(.$>=7 \\$7
169 .de tblend
170 .       br
171 .       if \\n[tblcol.ok] .tblcolend
172 .       if \\n[tblrow.ok] .tblrowend 1
173 .       tblrst