To be honest, my method has been pretty much obsoleted by groff's "write" requests. It had been based on the fact that troff had had no capability for writing larger blocks of text (i.e., multi-line chunks) to external files.
Here is a toy model of a much better approach. Just roff the file twice (use flags "-U -e") -- no need for a separate run to generate the TOC, it is generated automatically. In fact, this method is technically much superior (plus, the TOC doesn't have to be on a separate page) that I think I'll implement it in my macros instead of my previous method. (Note also that the technique is not really new -- LaTeX has been using an analogous approach for a *long* time.) .\" unsafe, eqn .em cleanup .wh -2c pagedone .sp 3c .ns .de cleanup .close toc .. .de pagedone .ch pagedone .ev 1 .if \\n%=1 .footer .if !\\n%=1 .header .bp .sp 3c .ns .ev .wh -2c pagedone .. .de header .sp |1c .tl '\\*[lefthead]''%' .tl ''\v'-.8m'\D'l \\n(.lu 0''' .. .de footer .sp 2v .tl '''%' .. .de section .nr secnum +1 .sp 2v .ne 4v .fp 8 TB .ft TB \\n[secnum].\ \ \\$* .sp .5v .ft TR .fp 8 TR .ds lefthead \\n[secnum].\ \ \\$* .write toc .tocline \\n% \\n[secnum].\ \ \\$* .. .de contents .char \(LC \ \ . .lc \(LC .ta \\n(.luR .sp 2v .ne 4v .ft TB Contents .sp .5v .ft TR .fp 8 TR .so troff.toc .open toc troff.toc .nr secnum 0 .. .de tocline .ds pagenum \\$1 .shift \\$*\a\h'-\w'\\*[pagenum]'u%\w'\(LC'u+\w'\(LC'u'\\*[pagenum] .br .. .EQ delim $$ gfont 8 grfont 8 .EN .contents .section Introduction Blahblah .bp 85 .section Experimental setup ($C H sub 3 - C H sub 2 O H$) Blahblah .section Results Blahblah .bp 107 .section Conclusions Blahblah _______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff