1#!/bin/sh 2# tocfix - move a DVI file table of contents to its proper position 3 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. 9 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 15# equals sign. 16 17# This program assumes that the DVI file has the standard Texinfo 18# format -- a titlepage, a copyright page, then the real text. 19 20# djm@cygnus.com (David MacKenzie) 21 22trap 'rm -f new-*.dvi title.dvi toc.dvi body_plus_toc.dvi body.dvi; exit 1' 1 3 15 23 24if [ $# -eq 0 ]; then 25 echo "Usage; tocfix dvifile..." >&2; exit 1 26fi 27 28for dvi 29do 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 35 mv new-$dvi $dvi 36 rm -f title.dvi toc.dvi body_plus_toc.dvi body.dvi 37done 38