🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #2158

How to forward reference chapters in troff

#2158
From: nils-peter.nelson
Date: Fri, 30 Nov 1990 15:55
43 lines
1574 bytes
As usual, I've forgotten who posted the question.
There is a way to forward reference chapters by number
in troff, but it requires two passes.  I always start
chapters with a macro, which guarantees a consistent
type font, size and position. The magic is to include
in that macro a ".tm" to divert information to stderr.
Then run troff, diverting stderr via "2>toc" (throw
away the actual troff output via >dev/null).
The information diverted is a mnemonic for the
chapter; references to the chapter will be via the mnemonic.
Here's an example:
.so toc2
.de CH
.sp2
.ce
\\$2
.sp
.tm \\$1
..
.CH NW "Networking"
blah blah
.CH SA "System Administration"
blah blah.
For further information, see Chaper \n(NW.
==
After running this as indicated, file toc will be:
NW
SA

Now run the one line awk progam:
awk <toc ' { print ".nr " $1 " " NR }' >toc2

File toc2 will now look like:
.nr NW 1
.nr SA 2

Now, re-run troff and all your forward references
will be to the correct chapter number.
(First time through, make sure toc2 exists,
e.g. "echo >toc2"; all the references will be
to chapter 0, but you're throwing away the output
anyway.)
Technical Details
Message-ID: <1990Nov30.155539.29209@cbnewsl.att.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!cbnewse!cbnewsd!cbfsb!cbnewsc!cbnews!cbnewsm!cbnewsl!npn

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!cbnewse!cbnewsd!cbfsb!cbnewsc!cbnews!cbnewsm!cbnewsl!npn
From: npn@cbnewsl.att.com (nils-peter.nelson)
Newsgroups: comp.text
Subject: How to forward reference chapters in troff
Keywords: troff, dwb
Message-ID: <1990Nov30.155539.29209@cbnewsl.att.com>
Date: 30 Nov 90 15:55:39 GMT
Organization: AT&T Bell Laboratories
Lines: 43