n-t-roff / heirloom-doctools

The Heirloom Documentation Tools: troff, nroff, and related utilities
http://n-t-roff.github.io/heirloom/doctools.html
Other
127 stars 23 forks source link

Multipage boxed table after table in keep with ms macros broken #116

Open rhaberkorn opened 1 year ago

rhaberkorn commented 1 year ago

The following example breaks under Heirloom Troff, but works with Groff. Although Groff prints a nonsensical "tbl-bug.ms:12: macro error: KE without KS or KF" error. It's the table in the keep that wreaks havoc. Unfortunately, using GNU tbl with Heirloom Troff also does not work well (and required full Groff compatibility).

Here's the code: tbl-bug.ms.gz Comments on how to build are in the first line.

Heirloom Troff: Heirloom Troff GNU Roff: GNU Roff

Do you have any idea on where to start to debug this? Also, can you explain Heirloom tbl's inefficient use of table space compared to GNU tbl?

reffort commented 1 year ago

I haven't done anything with troff in a long time, but my recollection is that the "x" column format option (a groffism to expand the column width) is not completely implemented in Heirloom's tbl. As your example shows, it does expand the column width, but it does not expand the content to match. I think I recall, but am not sure, that it also confuses "allbox".

The workaround is pretty simple: just don't use the "x" option. Set the column widths to whatever you want. If "allbox" still doesn't provide the expected result, it can be replaced by using "box" and adding the corresponding separator symbols to the format definition. (For examples, see Mike Lesk's tbl document.)

There is also the "expand" global option, which may provide a usable starting point. I'm not familiar with any of the standard macro packages, but your description doesn't seem to indicate a problem with the Heirloom version of -ms.

------- Original Message ------- On Wednesday, December 21st, 2022 at 7:38 AM, Robin Haberkorn @.***> wrote:

The following example breaks under Heirloom Troff, but works with Groff. Although Groff prints a nonsensical "tbl-bug.ms:12: macro error: KE without KS or KF" error. It's the table in the keep that wreaks havoc. Unfortunately, using GNU tbl with Heirloom Troff also does not work well (and required full Groff compatibility).

Here's the code: tbl-bug.ms.gz Comments on how to build are in the first line.

Heirloom Troff: Heirloom Troff GNU Roff: GNU Roff

Do you have any idea on where to start to debug this? Also, can you explain Heirloom tbl's inefficient use of table space compared to GNU tbl?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

rhaberkorn commented 1 year ago

The workaround is pretty simple: just don't use the "x" option. Set the column widths to whatever you want. If "allbox" still doesn't provide the expected result, it can be replaced by using "box" and adding the corresponding separator symbols to the format definition. (For examples, see Mike Lesk's tbl document.)

Unfortunately, the output is still weird even when not using expand option and the x specifier:

2023-01-06-222656_1261x657_scrot

Commenting out the keep and specifying only expand (no x whatsoever!) results in unexpected formatting as well:

2023-01-06-222736_1207x659_scrot

Interestingly, the behavior and output of Heirloom tbl is exactly the same as of Plan9 tbl.

rhaberkorn commented 1 year ago

Interesting. This is Neatroff with Heirloom's tbl. It at least does the table boxing correctly even in the presence of the keep.

2023-01-06-224949_1226x569_scrot

The x specifier still does not work which is not surprising.

g-branden-robinson commented 6 months ago

I haven't done anything with troff in a long time, but my recollection is that the "x" column format option (a groffism to expand the column width) is not completely implemented in Heirloom's tbl.

That's not precisely true. The tbl in Heirloom Doctools's ancestor DWB 3.3 troff supports the x column modifier.

$ cat table-without-x-column-modifier.roff 
.TS
tab(@);
L L.
left column@T{
Sed ut perspiciatis, unde omnis iste natus error sit
T}
.TE
$ DWBHOME=. ./bin/tbl table-without-x-column-modifier.roff | DWBHOME=. ./bin/nroff | cat -s
left column
              Sed  ut  perspiciatis,
              unde  omnis iste natus
              error sit

Now let's add the x column modifier.

$ cat table-with-x-column-modifier.roff 
.TS
tab(@);
L Lx.
left column@T{
Sed ut perspiciatis, unde omnis iste natus error sit
T}
.TE
$ DWBHOME=. ./bin/tbl table-with-x-column-modifier.roff | DWBHOME=. ./bin/nroff | cat -s
left column
              Sed ut perspiciatis, unde omnis iste natus  error
              sit

Where GNU tbl did innovate, as far as I know, was to support using the x modifier in more than one column per table.

There is also the "expand" global option, which may provide a usable starting point.

In my experience, this is not often useful advice. The expand region option expands (or shrinks) the gaps between table columns to (try to) fit the table to the line length (minus indentation), but allocates no additional room for text formatting. The formula for computation of text block width in the absence of w or x modifiers is in Lesk's 1978 paper (it also appears in the GNU tbl man page).