%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
%  Set parameters
%
\tolerance=10000
\hbadness=9999
\vbadness=9999
\clubpenalty=200
\widowpenalty=5000
\displaywidowpenalty=5000
\uchyph=-1
\adjdemerits=0
\hfuzz=6pt
\overfullrule=0pt
\def\load{\input } % insert path here if needed
\def\style#1{\load #1.sty}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Fonts                                                            Fonts
%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
\newcount\t@mpa
%
%  \f@ntselect takes the \f@ntname and proceeds from there
%
\def\f@ntselect#1{\def\f@ntname{#1}\scanf@ntsizes\loadf@nt}
%
%  \scanf@ntsizes looks for the best \f@ntindex for \f@ntsize.
%
\def\scanf@ntsizes{\t@mpa=0\relax%
\loop\expandafter\ifnum\csname f@ntsize\the\t@mpa\endcsname<\f@ntsize%
\advance\t@mpa by 1\relax\repeat%
\edef\f@ntindex{\the\t@mpa}}
%
%  \loadf@nt switches to the font given by \f@ntname and \f@ntindex
%
\def\loadf@nt{%
\expandafter\ifx\csname \f@ntname\f@ntindex\endcsname\relax
% preceding test for "font already loaded?" does not work.
% following tests for "filename constructable?" work, but
% they don't test "fontfile really exists?"
\expandafter\ifx\csname f@ntname\f@ntindex\endcsname\relax\else
\expandafter\ifx\csname f@nt\f@ntname\endcsname\relax\else
\edef\f@ntfile{\csname f@nt\f@ntname\endcsname%
\csname f@ntname\f@ntindex\endcsname}%
\expandafter\font\csname \f@ntname\f@ntindex\endcsname=\f@ntfile\relax
\fi\fi\fi
\csname \f@ntname\f@ntindex\endcsname}
%
\def\it{\f@ntselect{it}}
\def\rm{\f@ntselect{rm}}
\def\sc{\f@ntselect{sc}}
\def\bf{\f@ntselect{bf}}
\def\sl{\f@ntselect{sl}}
\def\tt{\f@ntselect{tt}}  % does not suppress hypenation.
%
%  Define \large, \Large, etc.
%
%  NB:  These should affect \baselineskip
%
\def\genericf@ntsize#1{\t@mpa=\b@seindex\advance\t@mpa by #1\relax
\ifnum\t@mpa<\f@ntsizeindex%\iw{Good}
\edef\f@ntindex{\the\t@mpa}%
\edef\f@ntsize{\csname f@ntsize\f@ntindex\endcsname}%
\loadf@nt\fi\ignorespaces}  % ign is a kludge
%
\def\tiniest{\genericf@ntsize{-6}}
\def\tinier{\genericf@ntsize{-5}}
\def\tiny{\genericf@ntsize{-4}}
\def\smallest{\genericf@ntsize{-3}}
\def\smaller{\genericf@ntsize{-2}}
\def\small{\genericf@ntsize{-1}}
\def\normalsize{\genericf@ntsize0}
\def\large{\genericf@ntsize1}
\def\larger{\genericf@ntsize2}
\def\largest{\genericf@ntsize3}
\def\huge{\genericf@ntsize4}
\def\hugest{\genericf@ntsize5}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Computer Modern Roman is the default font family
%
\def\f@ntrm{cmr}
\def\f@ntit{cmti}
\def\f@ntsc{cmcsc}
\def\f@ntsl{cmsl}
\def\f@ntbf{cmbx}
\def\f@nttt{cmtt}   % need to add math font support
%
\newcount\f@ntsizeindex\f@ntsizeindex=0
\def\f@ntsizedef#1#2{
\expandafter\def\csname f@ntsize\the\f@ntsizeindex\endcsname{#1}
\expandafter\def\csname f@ntname\the\f@ntsizeindex\endcsname{#2}
\advance\f@ntsizeindex by 1
}
%
\f@ntsizedef{50}{5}
\f@ntsizedef{60}{6}
\f@ntsizedef{70}{7}
\f@ntsizedef{80}{8}
\f@ntsizedef{90}{9}
\f@ntsizedef{100}{10}
\f@ntsizedef{110}{10 at 10.967pt}
\f@ntsizedef{120}{12}
\f@ntsizedef{144}{10 at 14.4pt}
%\f@ntsizedef{170}{17}
\f@ntsizedef{207}{10 at 20.733pt}
\f@ntsizedef{249}{10 at 24.867pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\pt#1{\def\f@ntsize{#1}\scanf@ntsizes\edef\b@seindex{\f@ntindex}}
%
\pt{100}\rm                        % default is 10pt roman
%
\catcode`\@=\c@tcode

\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
%  Make // switch into italics:                                     Italics
%
\let\sl@shedonce=/
\let\it@lcorrect=\/
\newcount\t@mpa
\newcount\t@mpb
\catcode`\/=13
\def/{\futurelet\nextt@k\sl@sher}
\def\sl@sher{\begingroup\ifx/\nextt@k\aftergroup\sl@shedtwice
\else\sl@shedonce{}\fi\endgroup}
\def\sl@shedtwice/{\begingroup\def\sl@shedtwice/{\endgroup\it@lcorrect}\it}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Make ** switch into bold:                                           Bold
%
\let\st@ronce=*
\catcode`\*=13
\def*{\futurelet\nextt@k\st@rred}
\def\st@rred{\begingroup\ifx*\nextt@k\aftergroup\st@rtwice
\else\st@ronce{}\fi\endgroup}
\def\st@rtwice*{\begingroup\def\st@rtwice*{\endgroup}\bf}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Make .. switch into small-caps, and ... become an ellipsis          Dots
%
\let\d@tonce=.
\catcode`\.=13
\def\d@tted{\begingroup\ifx.\nextt@k\aftergroup\d@ttwice
\else\d@tonce{}\fi\endgroup}
\def\d@ttwice.{\futurelet\nextt@k\d@tagain}
\def\d@tagain{\begingroup\ifx.\nextt@k\aftergroup\d@tthrice
\else\aftergroup\d@tonlytwice\fi\endgroup}
\def\d@tonlytwice{\begingroup\def\d@tonlytwice{\endgroup}\sc}
\def\d@tthrice.{\futurelet\nextt@k\d@tthree}
\def\d@tthree{\begingroup\ifx.\nextt@k\aftergroup\d@tfour
\else\dots\fi\endgroup}
\def\d@tfour.{\dots\thinspace\d@tonce}
\catcode`\.=12
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Footnotes                                                      Footnotes 
%
\def\onebr@cket{[}
\def\onecl@sebracket{]}
\catcode`\[=13
\catcode`\]=13
\def[{\futurelet\nextt@k\br@cket}
\def\br@cket{\begingroup\ifx[\nextt@k\aftergroup\br@ckettwice
\else\onebr@cket\fi\endgroup}
\def\br@ckettwice[{\unskip
\begingroup\catcode`\]=13\def]{\futurelet\nextt@k\cl@sebracket}%
% bad hack follows -- take this OUT!
\tr@emargins
\footnote\bgroup
}%
\def\cl@sebracket{\begingroup\ifx]\nextt@k\aftergroup\cl@sefootnote
\else\onecl@sebracket\fi\endgroup}
\def\cl@sefootnote]{\relax\egroup\endgroup}
\catcode`\]=12
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Section headers                                                Sections 
%
\everypar{\relax\futurelet\nextt@k\ch@ckpar}
\def\ch@ckpar{\t@mpb=0\relax
\begingroup\ifx>\nextt@k\aftergroup\s@ctionhead\fi\endgroup}
%
\def\s@ctionhead{\begingroup\ifx>\nextt@k\aftergroup\subhe@d
\else\aftergroup\s@ction\fi\endgroup}
%
\def\subhe@d>{\advance\t@mpb by 1\relax\futurelet\nextt@k\s@ctionhead}
%
\def\curs@ct{1}
\expandafter\def\csname s@ctname1\endcsname{0}
%
\newif\ifl@ttered
\def\UseLetteredSectionNames{\l@tteredtrue}
\def\DontUseLetteredSectionNames{\l@tteredfalse}
\DontUseLetteredSectionNames
%
\def\s@ctn@me{%
\ifl@ttered \t@mpb=\csname s@ctname1\endcsname\relax%
\advance\t@mpb by 64\relax%
\char\t@mpb\else%
\csname s@ctname1\endcsname\fi%
\t@mpb=1\relax%
\loop%
\advance\t@mpb by 1\relax%
\ifnum\t@mpb<\curs@ct%
.\csname s@ctname\the\t@mpb\endcsname%
\repeat}
%
\def\s@ction #1\par{%\iw{sec}  % for some reason, the par doesn't terminate
%                                when in ``read from terminal'' mode.
\ifnum\t@mpb>\curs@ct
\errhelp={For example, you may have tried going from a section to a
subsubsection without putting a subsection in between.}%
\errmessage{MITeX error: Subsections not nested correctly.}%
\else\advance\t@mpb by 1\relax%
\xdef\curs@ct{\the\t@mpb}%
\expandafter\xdef\csname s@ctname\the\t@mpb\endcsname{0}%
\advance\t@mpb by -1\relax%
\t@mpa=\csname s@ctname\the\t@mpb\endcsname%
\advance\t@mpa by 1\relax%
\expandafter\xdef\csname s@ctname\the\t@mpb\endcsname{\the\t@mpa}\fi%
% typeset header:
\par\bigskip\noindent{\raggedright
\ifnum\curs@ct=2\relax\bf\largest % section
\else\ifnum\curs@ct=3\relax\bf\large % subsection
\else\ifnum\curs@ct=4\relax\bf\normalsize % subsubsection
\else\normalsize\it % even lower....
\fi\fi\fi
\s@ctn@me\ \ignorespaces #1}%
\par\nobreak\smallskip\nobreak\noindent}
%%%%%%%%%%%%%%%%%%%%%%
\catcode`\@=\c@tcode

\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
\newdimen\leftm@rgin   \leftm@rgin=1.5in
\newdimen\rightm@rgin  \rightm@rgin=1in
\newdimen\topm@rgin    \topm@rgin=1in
\newdimen\bottomm@rgin \bottomm@rgin=1in
%
\def\leftmargin{\afterassignment\setmargins\leftm@rgin}
\def\rightmargin{\afterassignment\setmargins\rightm@rgin}
\def\topmargin{\afterassignment\setmargins\topm@rgin}
\def\bottommargin{\afterassignment\setmargins\bottomm@rgin}
%
\def\setmargins{%
\dimen255=\leftm@rgin \advance\dimen255 by -1in \hoffset=\dimen255
\dimen255=8.5in \advance\dimen255 by -\rightm@rgin 
\advance\dimen255 by -\leftm@rgin \hsize=\dimen255
\dimen255=\topm@rgin \advance\dimen255 by -1in \voffset=\dimen255
\dimen255=11in \advance\dimen255 by -\bottomm@rgin 
\advance\dimen255 by -\topm@rgin \vsize=\dimen255}
%
\catcode`\@=\c@tcode

\newcount\fcount\fcount=0
\let\ftnote=\footnote
\def\footnote{\global\advance\fcount by 1\relax\ftnote{$^{\number\fcount}$}}

%
%  Bibliography and Footnote hacks
%
%  Andrew Marc Greene
%
\newcount\Source \Source=0
%
\def\newsource#1#2#3{%  \newsource{code}{short_form}{long_form}
\global\advance\Source by 1
\expandafter\xdef\csname NUM.#1\endcsname{\the\Source}
\expandafter\gdef\csname SHORT.#1\endcsname{#2}%
\expandafter\gdef\csname LONG.#1\endcsname{#3}%
\expandafter\gdef\csname #1\endcsname{\cite{#1}}}
%
\def\CITELAST{0}
%
\def\cite#1{%  does a footnote citation
\xdef\CITETEST{\csname NUM.#1\endcsname}%
\ifnum\CITELAST=\CITETEST%
{\it Ibid.}\else%
\xdef\CITELAST{\csname NUM.#1\endcsname}%
\csname LONG.#1\endcsname%
\expandafter\gdef\csname LONG.#1\endcsname{\csname SHORT.#1\endcsname}\fi}

%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
\def\center{%
\noindent\leftskip=0pt plus 1fil\relax\rightskip=0pt plus 1fil\relax
\parfillskip=0pt\parindent=0pt\relax}
%
\def\picture#1{% Leave space for a picture later.
\nobreak\null\vskip #1\relax}
%
\catcode`\@=\c@tcode

%
%  Stolen from TeXhax V90 # 26
%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
\chardef \l@tter = 11
\chardef \@ther = 12
\newcount \c@unt 
\newcount \ch@rcode
\newif \ifd@bugging 
\ifd@bugging \let \m@ssage = \message \else \def \m@ssage #1{}\fi
%
\def \verbatim #1%
    {\begingroup
     \def \n@sted 
         {\begingroup
          \let \n@sted = \endgroup 
          \@nvironment 
          \ignorespaces
         }%
     \tt
     \edef \@nvironment 
          {\parindent = \the \parindent 
           \parskip = \the \parskip 
           \relax
          }%
     \parskip = 0 pt 
     \parindent = 0 pt
     \c@unt = 0 
     \loop 
            \ifnum \c@unt < `\A%
                   \s@ve \catcode \c@unt = \@ther
            \else  \ifnum \c@unt > `\z%
                          \s@ve \catcode \c@unt = \@ther
                   \else  \ifnum \c@unt > `\Z%
                                 \ifnum \c@unt < `\a%
                                        \s@ve \catcode \c@unt = \@ther
                                 \else  \s@ve \catcode \c@unt = \l@tter
                                 \fi
                          \else  \s@ve \catcode \c@unt = \l@tter
                          \fi
                   \fi
            \fi
            \advance \c@unt by 1
     \ifnum \c@unt < 128 % or 256 for the V3 sites ...
     \repeat
     \ch@rcode = `#1%
     \edef \@nvironment {\@nvironment \catcode \the \ch@rcode = \active \space}%
     \catcode \ch@rcode = \active 
     \uccode `\^^M = \ch@rcode 
     \@x \uppercase \@x {\@x \def \r@turn {\n@sted}}
     \uccode `\^^M = 0
     \@ctivecr
     \@ctivespace
     \v@id
    }%
%
\let \@x = \expandafter
\def \v@id {\futurelet \n@xt \v@idifspace}
\def \k@rn {\leavevmode \kern \fontdimen 2 \font \futurelet \n@xt \k@rnifspace}
\def \pr@nt {\char 32\relax}
\def \v@idifspace {\testn@xt {\afterassignment \v@id}}
\def \k@rnifspace {\testn@xt {}}
\def \AfterGroup #1{\global \def \@ftergroup {#1}\aftergroup \@ftergroup}
%
\def \s@ve #1#2=#3%
    {\ifnum #1#2 = #3%
     \else \edef \@nvironment{\@nvironment#1\the #2=\the #1#2 }#1#2 = #3%
     \fi
    }
%
\def \testn@xt #1%
    {\ifx  \n@xt \sp@c@
           \m@ssage {Next character is a space}%
           \let \n@xt = \relax
     \else \ifx  \n@xt \r@t@rn
                 \m@ssage {Next character is a return}%
                 \def \n@xt {#1\let \n@xt = }%
           \else \m@ssage {Next character is \meaning \n@xt}%
                 \let \n@xt = \relax
                 \@x \let \sp@ce = \pr@nt
           \fi
     \fi
     \n@xt
    }%
%
\catcode `\ = \active%
\def\sp@ce{ }%
\def\@ctivespace{\catcode`\ =\active\def {\v@id}\let\sp@c@= }%
\catcode`\ =10\relax
%
\catcode `\^^M = \active %
\def \r@turn {^^M}%
\let \r@t@rn = ^^M%
\def \@ctivecr %
    {\catcode `\^^M = \active %
     \def ^^M%
         {\@x \def \sp@ce {\k@rn}%
          \@x \let \@x \sp@c@ \@x =\sp@ce %
          \endgraf %
          \futurelet \n@xt \k@rnifspace %
         }%
     \let \r@t@rn = ^^M%
    }%
\catcode `\^^M = 5 %
%
\catcode `\@ = \c@tcode
\def \endverbatim {\endgroup \endgroup}

%
%  Let me explain how the template-generator works:
%
%  It goes down your list of column types, and for each one it
%  puts the template down.  It also defines something called
%  \b@tween that would go after this thing, but only if it ends
%  up between two fields (most often, an ampersand).
%
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
\def\t@bleparsechar{%
\let\n@xt=\t@bleparseend
\if\n@xttok l\t@blebetween\t@bleappend{\p@rm\hfil}\def\b@tween{&\ }%
\let\n@xt=\t@bleparseloop\fi
\if\n@xttok r\t@blebetween\t@bleappend{\hfil\ignorespaces\p@rm}%
\def\b@tween{&\ }\let\n@xt=\t@bleparseloop\fi
\if\n@xttok c\t@blebetween\t@bleappend{\hfil\ignorespaces\p@rm\hfil}%
\def\b@tween{&\ }\let\n@xt=\t@bleparseloop\fi
\if\n@xttok p\t@blebetween\let\n@xt=\t@bleparbox\def\b@tween{}\fi
\if\n@xttok |%
\ifx\b@tween\relax
\t@bleappend{\strut\vrule}\def\b@tween{\ }%
\else\t@bleappend{\ \strut\vrule}%
\expandafter\def\expandafter\b@tween\expandafter{\expandafter\ \b@tween}%
\fi
\let\n@xt=\t@bleparseloop\fi
\if\n@xttok\bgroup\t@blebetween\let\n@xt=\t@blelit\def\b@tween{}\fi
\if\n@xttok.\t@blebetween\t@bleappend{\catcode46=4% Make . a tab character
\hfil\p@rm\unskip.&\ignorespaces\p@rm\hfil}\def\b@tween{&\ }%
\let\n@xt=\t@bleparseloop\fi
%\if\n@xttok*\let\n@xt=\t@bleparseend\fi
\n@xt}
%
\def\t@bleparseerror{\errmessage{Error while parsing argument to "table"}}
\def\t@bleparse{\futurelet\n@xttok\t@bleparsechar}
\def\t@bleparseloop#1{\t@bleparse}
\def\t@blelit#1{\t@bleappend{#1}\t@bleparse}
\def\t@bleappend#1{\expandafter\def\expandafter\t@mp\expandafter{\t@mp #1}}
\def\t@blebetween{\expandafter\t@bleappend\expandafter{\b@tween}}
\def\t@bleparseend#1{}
\def\t@bleparbox p#1{\t@bleappend{\vtop{\hsize=#1\relax \p@rm}}%
\def\b@tween{&\ }\t@bleparse}
%
\def\table#1{\begingroup%
\smallskip
\let\hr@le\hrule \def\hrule{\noalign{\hr@le}}%
\let\b@tween=\relax
\catcode`\&=4\def\t@mp{}%
\t@bleparse #1*%
\def\p@rm{########}%
\edef\t@mp{\t@mp}%
\let\\=\cr%
%\show\t@mp
\halign\bgroup\span\t@mp\cr}
%
\def\endtable{\crcr\egroup\endgroup\smallskip}
%
\catcode`\&=12
\catcode`\@=\c@tcode

\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
%  \math{4+3*5}  should yield  19
%
\def\math#1{\m@thinit\m@theval #1)}
\def\m@threcurse({\m@thinit\m@theval}
\def\m@theval{\futurelet\q\m@thone}
\def\m@thone{%
\iftrue\let\next\m@therr\fi
%
%  Is q a macro?
%
\ifcat\q\relax\let\next\m@thmacro\fi
%
%  Is q a digit?
%
\if\q0\let\next\m@thdigit\fi
\if\q1\let\next\m@thdigit\fi
\if\q2\let\next\m@thdigit\fi
\if\q3\let\next\m@thdigit\fi
\if\q4\let\next\m@thdigit\fi
\if\q5\let\next\m@thdigit\fi
\if\q6\let\next\m@thdigit\fi
\if\q7\let\next\m@thdigit\fi
\if\q8\let\next\m@thdigit\fi
\if\q9\let\next\m@thdigit\fi
%
%  Is q an open parenthesis?
%
\if\q(\let\next\m@threcurse\fi
%
%  Is q a close parenthesis?
%
\if\q)\let\next\m@thend\fi
%
%  Is q an operator?
%
\if\q+\let\next\m@thop\fi
\if\q-\let\next\m@thop\fi
\if\q*\let\next\m@thop\fi
\if\q/\let\next\m@thop\fi
%
\next}
%
%  Main parse loop has been done.  Now we need the utility routines.
%
\newcount\m@tha\newcount\m@thb
%
\def\m@thinit{\begingroup\m@tha=0\m@thb=0\let\m@tholdop\m@thadd}
\def\m@thdigit#1{\multiply\m@thb by 10\advance\m@thb by #1\m@theval}
\def\m@thadd{\advance\m@tha by \m@thb}
\def\m@thsub{\advance\m@tha by -\m@thb}
\def\m@thmul{\multiply\m@tha by \m@thb}
\def\m@thdiv{\divide\m@tha by \m@thb}
\def\m@thop#1{%
\m@tholdop\m@thb=0
\if\q+\let\m@tholdop\m@thadd\fi
\if\q-\let\m@tholdop\m@thsub\fi
\if\q*\let\m@tholdop\m@thmul\fi
\if\q/\let\m@tholdop\m@thdiv\fi
\m@theval}
%
\def\m@thend){\m@tholdop\xdef\m@thtemp{\number\m@tha}\endgroup\m@thb=\m@thtemp
\ifx\m@tholdop\relax\let\next\m@thfinal\else\let\next\m@theval\fi
\next}
%
\def\m@thfinal{\number\m@thb}
\let\m@tholdop=\relax % this will remain true on the ``outside''
\def\m@therr{\message{Math parsing error -- bad character is:}\show\q}
\def\m@thmacro#1{\expandafter\m@theval#1}
\catcode`\@=\c@tcode
%
\immediate\write16{}
\immediate\write16{This is AMGTeX, Version 0.1 <15-Feb-1990>}
%
