🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #3365

Re: table of contents with -ms

#3365
From: graham
Date: Tue, 27 Jan 1987 12:19
73 lines
2986 bytes
marco@math.ucla.edu asks:
>
>I'm using the .NH section headers macros of the ms package.
>How can I have an automatically set table of contents printed at the 
>beginning of my text?

You can use the .XS and .XE macros which produce an index.  Since it
is inconvenient and unmaintainable to enter an index entry again, after
the heading definition, I have created a new macro .XH. For example:  
	.XH 2 "Title - several words must be in quotes"
.XH 0 replaces .SH, and .XH 1 replaces .NH 1, and so on for subchapters.
.XH with no parameter changes the numbering of chapters to lettering,
which I use for appendices.  (My page numbers are in the footer.)
Here is a simple form of the macro:

.	\" XH - macro to simplify table of contents
.de XH 
.ie "\\$1"" \{
.bp			# appendix starts on new page
.nr H1 0
.af H1 A
.\}
.el \{
.ie \\$1 \{
.if !\\$1-1 .bp		# new chapters start on a new page
.NH \\$1
\\$2
.XS
\\*(SN       \\$2
.XE
.\}
.el \{
.SH
\\$2
.XS \\n(PN
\\$2
.XE
.\}
.LP
.\}
..

Since nroff is one-pass, the index will be printed at the end of the
processing, using macro .TC or .PX.  You can move it to the front
manually.  I number it roman, by changing the macro .TC to the following: 
.	\" TC - table of contents at end of paper
.de TC
.br
.bp
.af PN i
.nr % 1
.nr PN 1
.PX "Table of Contents
.sp 2
..

Unfortunately only one index is possible, so if you're using XS-XE for
the table of contents, it's bad luck for a list of Tables or an index
to keywords.  I have an alternative index macro taken from the .(x 
.)x of -me macros which allows several indexes.  The originators of
the .XS macros, and even our local gurus, seem to think that there is
no difference between a table of contents and an index.  Simple -
they're at different ends of a book!  

Comments and improvements are welcome.
                                                                ____________
    Graham Tritt                SOWI, Department 34b1           |  ________|__
    Hasler AG, Belpstr. 23, CH-3000 Berne 14, Switzerland       |  |    _    |
                                                                |  |  _| |_  |
Telephone:    +41 31 632661                                     |  | |_ + _| |
X.400:      graham@hslrswi.hasler                               |__|   |_|   |
Bitnet:     graham%hslrswi.UUCP@cernvax.BITNET                     |_________|
Uucp:       ... {seismo,ukc, ... }!mcvax!cernvax!hslrswi!graham
Technical Details
Message-ID: <419@hslrswi.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!seismo!mcvax!cernvax!hslrswi!graham

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!seismo!mcvax!cernvax!hslrswi!graham
From: graham@hslrswi.UUCP
Newsgroups: comp.text
Subject: Re: table of contents with -ms
Message-ID: <419@hslrswi.UUCP>
Date: Tue, 27-Jan-87 07:19:52 EST
Article-I.D.: hslrswi.419
Posted: Tue Jan 27 07:19:52 1987
Date-Received: Tue, 3-Feb-87 19:12:47 EST
Organization: Hasler AG, Berne, Switzerland
Lines: 73
Keywords: index, troff, ms, table of contents