#!/bin/sh
# dvidvi 1.0, Copyright (C) 1988-91, Radical Eye Software
# a5booklet (c) 1997 David van Leeuwen

# Takes a .dvi file as argument.  The .dvi file should contain 
# A5 sized pages.  Output are two .dvi files with A4, landscape 
# pages that can be printed on front and back.  Reshuffle pages 
# before stapling them!

# We don't use TeX page numbers, but real ones. 

file=$1
[ $# -gt 0 ] || { echo "No input .dvi file specified";  exit; }
[ -e $file -o -e $file.dvi ] || { echo "Input file $file not found";  exit; }

name=`basename $file .dvi`

name1=$name-1
name2=$name-2

# from manpage dvidvi:
dvidvi -m '4:-1,2(14.85cm,0)' $name $name1
dvidvi -m '4:-3,0(14.85cm,0)' $name $name2

cat <<EOF

You can view the files by issuing
xdvi -paper a4r $name1
xdvi -paper a4r $name2

You can print the files using
dvips -ta4 -tlandscape $name1
dvips -ta4 -tlandscape $name2

EOF

