[comp.text] Need to change table of contents page numbering in MM

daw@houxs.ATT.COM (David Wolverton) (01/06/89)

I'm writing an "appendix" macro in troff with MM macros.  I want
the pages numbered like A-1, A-2, etc.  I can get this numbering
at the top of the pages themselves, but the page numbers listed
in the table of contents (TOC) come out as 1.

I'm resetting the page number in register P to 1 for each appendix,
and using .HU to print the appendix title, which is why I get the
number 1 in the TOC for each appendix.  I don't mind abandoning .HU
if there is some other way to put an entry into the TOC that has
the same appearance as that generated by .HU, except with page
numbers like A-1, B-1, etc.

Anybody have an idea?

Dave Wolverton
...!att!houxs!daw or daw@houxs.att.com

morrell@hpsal2.HP.COM (Michael Morrell) (01/07/89)

/ hpsal2:comp.text / daw@houxs.ATT.COM (David Wolverton) /  2:32 pm  Jan  5, 1989 /
I'm writing an "appendix" macro in troff with MM macros.  I want
the pages numbered like A-1, A-2, etc.  I can get this numbering
at the top of the pages themselves, but the page numbers listed
in the table of contents (TOC) come out as 1.

Anybody have an idea?

Dave Wolverton
...!att!houxs!daw or daw@houxs.att.com
----------

Try using the following:

  .HM A
  .nr H1 0

before your first appendix.  This will set the heading style for the
top level section to A, B, C, ... .  Then you can use

  .H 1 "Appendix"

and the table of contents should be fine.

crocker@ihlpf.ATT.COM (Crocker) (01/07/89)

I use the following macro to start a new appendix.

.nr aP 0
.af aP I
.de AP
.nr aP +1
.nr p 1 1
.PH "''- \\\\\\\\nP -''"
.SK
.PH "''- \\\\\\\\nP -'\\fRAppendix \\n(aP \- \\\\\\\\n+p\\fP'"
.tl ''\\fBAppendix \\n(aP \- \\$1\\fP''
.am >C
.)T 1 0 "" "Appendix \\n(aP \- \\$1" \\nP
\\..
.sp 2
..

I use it as follows:

.aP "Appendix title"

The first page of the appendix looks like:

		- 14 -		Appendix I - 1
		
	Appendix I - Appendix title

...

The next page looks like:

		- 15 -		Appendix I - 2

...

What shows up in the table of contents is

...
9. Conclusions . . . . . . . . . 13
Appendix I - Appendix title  . . 14

I prefer the above numbering scheme to the one proposed in the base
note since it gives some notion of the relative position of the
various appendices.  I'm sure that appendix A starts at page A-1, but
that doesn't give me much of a clue as to where to find it relative
to the other appendices, nor does it give a hint as to the size of
appendix A.

If, however, you still want to have it come out at A-1 (or in my
case I-1), you need to use the following macro definition:

.nr aP 0
.af aP A
.de AP
.nr aP +1
.nr p 1 1
.PH "''- \\\\\\\\nP -''"
.SK
.PH "''- \\\\\\\\nP -'\\fRAppendix \\n(aP \- \\\\\\\\n+p\\fP'"
.tl ''\\fBAppendix \\n(aP \- \\$1\\fP''
.am >C
.)T 1 0 "" "Appendix \\n(aP \- \\$1" \\n(aP-1
\\..
.sp 2
..

I'm pretty sure that this will work.  This leaves the sequential
page numbering on the pages.  Change the .PH lines to remove that
if you don't want it. 

Ron Crocker			| 
AT&T Bell Laboratories		| Affiliation given for identification
Naperville, IL  60566		| purposes only.
(312) 416-5262			|

daw@houxs.ATT.COM (David Wolverton) (01/11/89)

Many thanks to all who responded to my original plea, and especially
to Bill Stubblebine (HP) and Ron Crocker (AT&T) who pointed me to the
.)E and .)T internal macros of the MM macro package.  I have included
below my final macros, for your edification and amusement.  The .)E
macro redefinition is different from the original MM macro it replaces
only in the fifth argument to the .)T call.

	.H 1 "Sample Program"
	This sample file demonstrates the .aH macro.
	Use .aH after all sections.
	.de aH
	.nr Hu 1	\" put headings in table of contents
	.nr Hc 1	\" centered heading
	.nr a +1
	.af a A
	.nr p 0 1	\" reset page counter to 1
	.PH "''- \\na-\\\\\\\\n+p -''"
	.SK
	.HU "Appendix \\na: \\$1"
	..
	.\" MM-related macro to get appropriate TOC numbering
	.de)E
	.ds}3
	.if\\n(:S .ds }3 \\n(H1
	.am>C
	.)T \\n(;1 \\$1 "\\*(}0" "\\$2" \\na-\\np \\*(}3
	\\..
	..
	.aH "First Appendix"
	appendix text for first appendix
	.aH "Second Appendix"
	appendix text for second appendix
	.PH ""
	.TC "" "" 3

The above file results in the following nroff output (whitespace has
been scrunched to make viewing easier; this is 4 pages of output):

                                  - 1 -

       1.  Sample Program

       This sample file demonstrates the .aH macro.  Use .aH after
       all sections.


                                 - A-1 -

                        Appendix A: First Appendix

       appendix text for first appendix


                                 - B-1 -

                        Appendix B: Second Appendix

       appendix text for second appendix



                                 CONTENTS


       1.  Sample Program.....................................    1

       Appendix A: First Appendix.............................  A-1

       Appendix B: Second Appendix............................  B-1

                                  - i -


Dave Wolverton
att!houxs!daw