🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #635

Re: troff -ms and keeps

#635
From: Jaap Akkerhuis
Date: Wed, 23 Aug 1989 21:18
46 lines
2205 bytes
> 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
Technical Details
Message-ID: <sYwlGl200jbYACNGcC@andrew.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!jaap+
References: <89Aug23.003836edt.19494@me.utoronto.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!andrew.cmu.edu!jaap+
From: jaap+@andrew.cmu.edu (Jaap Akkerhuis)
Newsgroups: comp.text
Subject: Re: troff -ms and keeps
Message-ID: <sYwlGl200jbYACNGcC@andrew.cmu.edu>
Date: 23 Aug 89 21:18:41 GMT
References: <89Aug23.003836edt.19494@me.utoronto.ca>
Distribution: na
Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA
Lines: 46
In-Reply-To: <89Aug23.003836edt.19494@me.utoronto.ca>