graham@hslrswi.UUCP (01/27/87)
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