#!/bin/sh

# $Id: pubref.sh,v 1.1 2002/11/04 03:45:58 gerkey Exp $
#
# pubref.sh - a simple script to insert publication references into
#             your postscript documents.  It will insert a header at the
#             top of the first page.  the header will be of the form:
#
#                In Proceedings of the Intl. Conf. on Foo
#                   pages 2-4, Los Angeles, CA, July, 2001
#
#             the new postscript will go to stdout.
#
# NOTE: this script counts on your document obeying the Adobe structured
#       comment convention (i.e., the first page will be marked by the
#       the string "%%Page: 1 1").  if you made the poscript with dvips,
#       then there should not be a problem.

# USAGE:
#
#   pubref.sh <booktitle> <address> <infile.ps>
#
#      <booktitle> : the string to be printed in italics after the word
#                    "In" on the first line of the header
#
#      <address>   : the string to be printed on the second line (could be
#                    an empty string)
#
#      <infile.ps> : the postscript file to process. if <infile.ps> is 
#                    "-" or omitted, then we read from stdin.
#


if [[ $# < 2 ]]; then
 echo "USAGE: pubref.sh <booktitle> <address> <infile.ps>" > /dev/stderr
 echo "" > /dev/stderr
 echo "For example:" > /dev/stderr
 echo "  pubref.sh \"Proc. of Intl. Conf. on Foo\" \"LA, CA, 2001\" foo.ps" > /dev/stderr
 exit
fi

sed "1,/^%%Page: 1 1/s//&\\
% -----------------------------------------------------------\\
% Reference\\
% -----------------------------------------------------------\\
\/Times-Roman findfont 12 scalefont setfont\\
40 760 moveto\\
(In) show\\
55 760 moveto\\
\/Times-Italic findfont 12 scalefont setfont\\
($1) show\\
\/Times-Roman findfont 12 scalefont setfont\\
55 748 moveto\\
($2) show\\
% -----------------------------------------------------------/" $3


