groff
[Top][All Lists]
Advanced

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

RE: [Groff] floating keeps and tbl usage


From: Ted Harding
Subject: RE: [Groff] floating keeps and tbl usage
Date: Thu, 07 Sep 2000 13:03:00 +0100 (BST)

On 06-Sep-00 Steckl, A. David wrote:
> Is there anyway to use a floating keep on groups of rows within a
> table?
> This is a problem for me as I have a multi-page table which has
> groupings which need to be intact. If you could refer me to any
> resources or answer this query I'd really appreciate it. Thanks.

A very interesting question ("maintainer-speak" for "you'll be lucky
to get a good answer, but let's think about it").

Since 'tbl' is normally used as a pre-processor to troff, there is
no way you can plant a "floating keep" (e.g. .KF ... .KE as in
tmac.s) and expect this to influence what 'tbl' itself does with
its input (which would amount to re-ordering the lines of the table,
but before they're formatted since troff one sees them later).

I have tried a variant or two of the mechanism suggested for ".BP"
to insert a page-break in a table (see "man tbl"), such as

  .de FKS
  .ie '\\n[.z]'' .KF
  .el \!.FKS
  ..
  .de FKE
  .ie '\\n[.z]'' .KE
  .el \!.FKE
  ..

but this fails with the messages
  :0: macro error: diversion open while ejecting page (recovering)
  :0: macro error: KE without KS or KF

If any ingenious soul out there can create a variant of this approach
which does work, it would be most useful.

As a stop-gap (definitely not perfect, but it should handle many cases)
you can call tbl from within troff using the .sy command. This would
be extremely cumbersome, since it would involve making a new table
for each line of the original table. It would work like this (I have
checked that the following does produce correct output and that the
floating keep works as desired, using ms macros for .KF/.KE).
The first line sets the "display drop" register \n[DD] to zero
so that the ms-macros .TS/.TE do not introduce extra spacing
as they usually do.

  .nr DD 0
  ...........................
  .open stuff temp.tbl
  .write stuff .TS
  .write stuff tab(#);
  .write stuff n l.
  .write stuff "001#These lines can be broken
  .write stuff .TE
  .close stuff
  .sy tbl temp.tbl > stuff.out
  .so stuff.out
  [and several similar]
  .KF
  .open stuff temp.tbl
  .write stuff .TS
  .write stuff tab(#);
  .write stuff n l.
  .write stuff "050#These lines must be kept together
  .write stuff .TE
  .close stuff
  .sy tbl temp.tbl > stuff.out
  .so stuff.out
  [and several similar]
  .KE
  .open stuff temp.tbl
  .write stuff .TS
  .write stuff tab(#);
  .write stuff n l.
  .write stuff "070#These lines can be broken
  .write stuff .TE
  .close stuff
  .sy tbl temp.tbl > stuff.out
  .so stuff.out
  [and several similar]

Clearly, you can condense some of this into macros, as

  .de TLS
  .open stuff temp.tbl
  .write stuff .TS
  .write stuff tab(#);  [or .write stuff \\S1 for the global options]
  .write stuff n l.     [or .write stuff \\$2 for the column options]
  ..
  .de TLE
  .write stuff .TE
  .close stuff
  .sy tbl temp.tbl > stuff.out
  .so stuff.out
  ..

and then
  .TLS   [or .TLS "tab(#);" "n l."]
  .write stuff "001#These lines must be kept together
  .TLE
etc.

In real life, with a table of many lines, it would be useful
to set up a small 'awk' script to manage the insertions of
.TLS and .TLE etc.

You would have to be very careful about handling horizontal and vertical
lines and boxes, and probably there is no way to make vertical spanning
work in the above simple scheme (though, depending on how much
"hand-crafting" you were prepared to do, you could manage this
by grouping such blocks of table input lines between a single
pair of .TLS/.TLE

I hope this helps, and if anyone can come up with a better idea then
please let us know!

Best wishes to all,#
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 284 7749
Date: 07-Sep-00                                       Time: 13:03:00
------------------------------ XFMail ------------------------------

reply via email to

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