From: cortesi@informix.com (David Cortesi)
Newsgroups: comp.text.frame
Subject: Re: Autonumbering page numbers for chapter TOC
Date: 29 Dec 92 17:30:53 GMT
Organization: Informix Software, Inc.

In article <1992Dec29.025734.29052@cbnewsj.cb.att.com> ralph@cbnewsj.cb.att.com (Ralph Brandi) writes:
>Okay, my first query was so successful I've got another....
>
>I've got multi-chapter books with complex page numbers, autonumbered
>with an invisible ChapterNumber tag.  In addition to the book-wide
>TOC, the format dictates chapter TOCs.  But when I generate the TOCs
>directly from the file, all I get is page numbers, no chapter
>numbers. [complicated, failed attempt details omitted...]

I see this subject of chapter TOCs isn't in the FAQ, maybe it should be?

Your chapter TOCs are documents, and as such they need to be in the
book file as book components.  You use a two-stage generation process
to create them.  At least, this is the only way I've ever found.

1) Each chapter, as you note, has an invisible ChapterNumber paragraph
which represents the chapter's number.  Two notes on this:

      * the best way to make it "invisible" is to give it a spot
	color such as "magenta."  Then you can use the View:Spot Colors
	dialog to display that color for editing or hide it for printing.
	You can not use a conditional tag for this purpose since hidden
	conditional text is removed from the document and cannot be used
	as a cross-reference source.

      * the ChapterNumber tag does not need to be in the para catalog,
	and probably shouldn't be -- it clutters the catalog display
	and invites tinkering by writers.  Just put the tag manually
	on one paragraph in the document template's first page.
	
2) The chapter TOC is a unique document and requires a template 
different from your chapter contents template.  In the TOC template,
the ChapterNumber para uses the + autonumber to increment by one.

3) In the template for a chapter contents document there must *also*
be an invisible ChapterNumber para, but in this one, the number
is not repeat *not* incremented, only used.

4) Aside from the chapter (auto)number, the paratext of the
invisible ChapterNumber paragraph should be the text of
the chapter title, for use in cross references.  Thus you can have
an xref format ChapterNumber of <$paranum[ChapterNumber]>, and
an xref format ChapterTitle of <$paratext[ChapterNumber]>.  Always
use these instead of typing the actual number or title.

5) Each time you create a chapter contents document, you also create
its matching TOC document.  You fill in the chapter title and other
chapter-unique items in *both* files.

6) Now you add *both* files to the book, the chapter TOC document
first, then the chapter contents.  Their "setups" differ:

				TOC		contents

	para numbering		continue	continue
	page numbering		restart at 1	continue
	starting side:		right		right or next-avail
						as you prefer

Because the chap number increments in the TOC while the page number
restarts, each TOC begins on page #-1.  In the contents files the chap
number does not increment and the page number continues, so they begin
on page #-3 (typically).

Also in the setup you must *manually* type in the chapter number
as the page-number-prefix value for generated page numbers.
Manually. Even though the numbers are dynamically generated and
picked up automatically in headers and xrefs, you still have to
put them in *manually* in the book setup.  Go figure.

7) Now generate the book: the chapter numbers are produced and
should show up properly in the headers of all pages.  However,
the TOCs are as yet empty.

8) So now open each chapter contents file indivually and use
File:Generate to generate a table of contents. If the TOC documents
have the appropriate filenames, Frame will use them, putting
contents lines into them.  (Of course you have already tinkered
with this to get the format right when creating the TOC template.)

9) Some TOC files may now be longer than they were before.  So you
repeat step 7 to adjust the page numbers, and then repeat step 8
to correct the TOC contents.

This scheme can be extended to multi-document chapters but that
is best left as an exercise for the compulsive...

Dave Cortesi
Newsgroups: comp.text.frame,comp.text.desktop,misc.writing,dfw.general