> The problem occurs when your table spans pages. Since you > are creating the gray line _after_ the current line, > sometimes you get an extra gray line on the first page, and > other times you get a double gray line on the second page.
Indeed. Just to clarify, filling the *next* line ahead of time was intended for tables which have both horizontal rules and fills. On a high-resolution device you can fill right up to the rule, but at screen resolutions the viewer software has to round the coordinates and might overpaint the previously drawn rule with a fill. This looks ugly. Thus, my approach of already filling the next line, thereby ensuring that the rules bordering a table line always get drawn after the fill. However, this approach unfortunately only works if the table does not get broken across pages at unpredictable positions. If you have long tables which must get broken across pages automatically, you only have the choice of filling (or not filling) the *current* line, and possibly avoiding horizontal rules. (Unless you're willing to modify tbl to add real support for fills.) In this regard, your solution works correctly, but it still has a feature which has bothered me, namely that the fills are tied to specific lines in the table (which might indeed be what you want). But suppose I always wanted to fill the *even* lines of the table on every page. Then the decision whether or not to fill a specific line must be delayed until it is known whether that line is an even or odd line on the page it will appear on. Since tbl uses diversions to test whether a table line will still fit on the current page, we need to embed the decision to fill (or not to fill) into the content in such a way that it survives this diversion and becomes active when the diversion is finally replayed onto the page. Fortunately, that is indeed possible using the \? escape, as show in the attachment. This solution alternates between a filling and a non-filling macro (F1 and F0, both triggered by \*Z in the table), and resets the fill mode on every table header (\*X or \*Y in the table header; \*Y allows the header to have a separate fill using F2). I have also decided to add dummy columns on the left and right, so that the fills always start at the same horizontal position, independent of the alignment of the first data column.
.\" tbl mm .\" ---------------------------------------------------------------- .de TP 'SP 1i .. .\" ---------------------------------------------------------------- .nr TW 0 .nr F 0 .defcolor tblfill1 rgb .9 1 .8 .defcolor tblfill2 rgb 1 .9 .8 .ds X \\?\R'F 1'\\? .ds Y \\?\R'F 1'\\*(F2\\? .ds Z \\?\R'F 1-\\\\nF'\\\\*(F\\\\nF\\? .ds F0 .ds F1 \Z'\v'0.3v'\M[tblfill1]\D'P 0 -1v \\n(TWu 0 0 1v'' .ds F2 \Z'\v'0.3v'\M[tblfill2]\D'P 0 -1v \\n(TWu 0 0 1v'' .\" ---------------------------------------------------------------- .TS H tab(~); L1 Lb Lb Lb 1L L Lb Lb Lb L L N N N L. \*Y~AAAAA~BBBBB~CCCCC \*Y~DDDD~EEEE~FFFF _ .TH \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 \*Z~1~2~3 \*Z~4~5~6 \*Z~7~8~9 \*Z~11~22~33 \*Z~44~55~66 \*Z~77~88~99 \*Z~111~222~333 \*Z~444~555~666 \*Z~777~888~999 .TE
tblfill.pdf
Description: Adobe PDF document
