groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there any way to make alternate rows of a table have a light gray


From: Tadziu Hoffmann
Subject: Re: Is there any way to make alternate rows of a table have a light gray background?
Date: Tue, 23 Nov 2021 16:47:40 +0100
User-agent: Mutt/1.11.4 (2019-03-13)

>  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.


Attachment: tblfill.ro
Description: Text document

Attachment: tblfill.pdf
Description: Adobe PDF document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]