[net.text] Table of contents help for troff - please

siritzky@acf2.UUCP (Brian Siritzky) (08/06/85)

We need some help!
We have formatted a book using troff with the 'me' package. (Don't ask me
why, I just help out.) Anyway, the book has 12 chapters and 3 or 4 appendices.
It is much too long to run through troff in one run. At the end of each
chapter we generate a table of contents for that chapter. Now we want to merge
them all together. We use the '.xp' to print out the TOC. Is there a way to
divert part of the output to a different file? Or can anyone suggest another 
way? Each chapter starts page numbering anew, so that is no problem, all we 
need is a way to write the TOCs somewhere and then merge them. Thanks.

	Brian Siritzky
	Courant Institute of Mathematical Sciences,
	251 Mercer Street, New York, NY 10012
	(212) 460-7239
	
	siritzky@acf2

chris@hwcs.UUCP (Chris Miller) (08/10/85)

In article <1710002@acf2.UUCP> siritzky@acf2.UUCP (Brian Siritzky) writes:
> ...
>We have formatted a book using troff with the 'me' package. ...
>.... At the end of each
>chapter we generate a table of contents for that chapter. Now we want to merge
>them all together. We use the '.xp' to print out the TOC. Is there a way to
>divert part of the output to a different file? ...

The only way to divert output from [nt]roff that I am aware of (at least
int the versions normally distributed with V6, V7 and 4.xBSD; I don't
know whether anyone has extended it since) is to use the ".tm" macro
which writes a "terminal message" to the standard stream.  Of course,
if you use ".tm" for diverted output then any error messages written in
this way by the macro package get interspersed with your TOC.

To catch the standard error stream, either do
	troff -me chapterN.n >chapterN.out 2>>toc
if you use the Bourne shell or do
	(troff -me chapterN.n >chapterN.out) >&toc
from the Cshell (horrible, isn't it - I like the CShell, but sometimes ...
however, this is net.text, not net.unix).

I have used this technique for capturing and producing the index of
a book; I also have a post-processor (alternative versions in Spitbol
and Icon) for generating a troff file to print the sorted index, merging
duplicate entries, collecting common entries under a single main heading,
etc., which I could post or supply by mail if there is interest.

	


-- 
	Chris Miller, Heriot-Watt University, Edinburgh
	...!ukc!{cstvax,kcl-cs}!hwcs!chris   chris@hwcs.uucp