[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] moving TOC to start
From: |
Tadziu Hoffmann |
Subject: |
Re: [Groff] moving TOC to start |
Date: |
Tue, 27 Sep 2005 15:06:15 +0200 |
User-agent: |
Mutt/1.5.6i |
> does anyone have any simple methods for placing the table of contents
> at the start of the output file ?
>
> I have done it manually with Postscript output and should be able to
> script that, but if anyone has other suggestions I would appreciate
> hearing from them.
I think manipulating the intermediate output given to the device
postprocessor is easier than manipulating the final device code
(ps, in your case). Something like this:
groff -ww -b -Tps -Z [other options] [*roff-file] |
sed -f shuffle.sed | grops >[ps-file]
rm troff.sort
with shuffle.sed being:
#!/bin/sed -f
/^p1$/s/p1/# -- cut here --/
/^# -- cut here --$/,/^# -- cut here --$/w troff.sort
/^# -- cut here --$/,/^# -- cut here --$/c\
p1
/^x trailer$/d
/^x stop$/{
s/.*/p1/
r troff.sort
a\
x trailer\
x stop
}
Note that this particular program works only if page number 1
appears twice in the document. Everything from the second
page 1 to the end of the file is moved to the beginning.
I usually set the page number back to 1 on the title page
and set the number format to roman (so that the title page
is page i), and format the table of contents at the very end,
like this:
[page 1] [page 2] ... [last page] [page i] [page ii] ... [contents]
which gets shuffled to
[page i] [page ii] ... [contents] [page 1] [page 2] ... [last page]
Thus all the front matter has roman page numbers and the "real"
content has arabic page numbers.