2 # tocfix - move a DVI file table of contents to its proper position
4 # TeX puts the table of contents at the end of the DVI file.
5 # If you're printing multiple pages per sheet, you can't fix it
6 # on the printout. This program moves the TOC to be right after
7 # the titlepage and copyright page.
8 # It's a safe no-op to run this program on a DVI file more than once.
10 # Some explanation: the TOC has negative page numbers, represented
11 # to dviselect by an underscore. The titlepage and copyright page
12 # have TeX page numbers 1 and 2, but so do the first two pages of the
13 # first chapter. So we have to use absolute, as opposed to TeX,
14 # page numbers to get them right, represented to dviselect by an
17 # This program assumes that the DVI file has the standard Texinfo
18 # format -- a titlepage, a copyright page, then the real text.
20 # djm@cygnus.com (David MacKenzie)
22 trap 'rm -f new-*.dvi title.dvi toc.dvi body_plus_toc.dvi body.dvi; exit 1' 1 3 15
25 echo "Usage; tocfix dvifile..." >&2; exit 1
30 dviselect
-i $dvi -o title.dvi
=1:2
31 dviselect
-i $dvi -o toc.dvi
:_1
32 dviselect
-i $dvi -o body_plus_toc.dvi
=3:
33 dviselect
-i body_plus_toc.dvi
-o body.dvi
1:
34 dviconcat
-o new-
$dvi title.dvi toc.dvi body.dvi
36 rm -f title.dvi toc.dvi body_plus_toc.dvi body.dvi