#!/bin/csh -f

# Usage: makeinclass fileroot

# You can actually include an extension in fileroot, but you get the
# same behavior from "makeinclass foo.tex" or "makeinclass foo.dvi" as from
# "makeinclass foo".

# This command creates a slightly modified version of fileroot.tex on
# fileroot-inclass.tex by expanding margins about as much as possible.

umask 66

set tempfile = /tmp/makeinclass.$user.$$

set inputbase = $1:r

sed -n '1,/inchmargs/p' $inputbase.tex > $tempfile
echo '\usepackage{feetdown}\pagelengthen{1.8in}\pagewiden{1.4in}' >> $tempfile
sed -n '/inchmargs/,$p' $inputbase.tex | egrep -v '(\\pagelengthen|\\pagewiden)' | tail -n +2 >> $tempfile

sed 's+%INCLASS-ONLY ++' $tempfile > ${inputbase}-inclass.tex

rm -f $tempfile
