[comp.text] troff -ms and keeps

zougas@me.utoronto.ca ("Athanasios(Tom) Zougas") (08/23/89)

I have a problem in troff using the -ms macro.  I'm trying
to automatically generate a list of tables with page numbers.
I put the tables inside .KF/.KE floating keep for obvious reasons.

The problem is that if the table is located at the point it
is generated, the page number I grab from \n(PN is fine. BUT,
if the keep floats to the NEXT page, the page numbering is
off by one.  So...how do I get the actual page the keep
ends up on?

If you know what I'm talking about :-) and you can help solve
my problem, please e-mail me, or post if it bounces.

Thanx,

Tom.

-- 
I can be reached at...

   CDNNET: zougas@me.utoronto.ca
   CSNET:  zougas@me.toronto.edu
   BITNET: zougas@me.UTORONTO.BITNET

jaap+@andrew.cmu.edu (Jaap Akkerhuis) (08/24/89)

> Excerpts from netnews.comp.text: 23-Aug-89 troff -ms and keeps
> Tom@me.utoronto.ca (700)

> I have a problem in troff using the -ms macro.  I'm trying
> to automatically generate a list of tables with page numbers.
> I put the tables inside .KF/.KE floating keep for obvious reasons.

> The problem is that if the table is located at the point it
> is generated, the page number I grab from \n(PN is fine. BUT,
> if the keep floats to the NEXT page, the page numbering is
> off by one.  So...how do I get the actual page the keep
> ends up on?

This has nothing to do with the -ms package. It is a general problem.
The .KS .KE stuff is actually diverting the text. You don't want to have
the page number on the moment that input is diverted, but on the moment
that it is read back. The proper way to do this is to test the .z
register to determine the whether or not you are in a diversion and act
accordingly.

This is easely done in a recursive way using the transparent indicator
macro. Here is the main idea:

.\" put page number on the moment we actually print on the error stream:
.\"
.de Pn
.ie '\\n(.z'' .tm page number is \\n%
.el \\!.Pn
..
.\"
.\" explanation:
.\"	if the current diversion name is empty, print the page number on the
error output
.\"	else call ourself via the transparent mechanism,
.\"	so we will only put it out when the diversion gets read back
.\"	..

Credits:. This is technique is stolen from the .ix macro invented by
Ravi Sethi.

> If you know what I'm talking about :-) and you can help solve
> my problem, please e-mail me, or post if it bounces.

I thought that this solution deserved a wider audience.

	jaap