%
%  This is MITeX, by Andrew Marc Greene
%  Copyright (C) 1989, 1990
%  All rights reserved
%  
%
%    Italics are obtained with //italics//
%    Boldface is obtained with **boldface**
%    Small Caps are obtained with ..Small Caps..
%    Section headers are defined as paragraphs beginning with >
%    Subsections begin with >>, et cetera.
%    Three periods (...) are converted to \dots{}
%    Fonts automatically loaded on demand.
%    Footnotes entered as [[footnote]].
%  / Verbatim done with "verbatim"
%  / A pleasant error handler.
%  * Tabs should be entered by defining columns in the input file and
%      using that to define the input for the columns.
%  * Appropriate behaviour for floats.
%  * Safeties on Plain TeX commands.
%  * Document ends with ``end'' in a paragraph by itself.
%  * Font size switches with <^^really large^> and <_small_>.
%  * Nop with <>
%  * \rawTeX ... \endgroup
%  * <$ math $> and <$$ displaymath $$>
%    $ % ^ _ & # are catcode ``other''  (what about tilde?)
%  * <% comments %>
%  * < and > don't give Spanish punctuation.
%  * Bibliography info in prologue, then \foo does correct footnote
%      citation (long form, op cit, ibid)
%    My own backslash parser
%    Ability to parse a prologue like this:
%
%         article
%         title=A New Input Style for \TeX
%         author=Andrew Marc Greene
%         date=4 Oct.~1989
%         begin
%
%
%  In short, the goals are two-fold.  First, we want to make the input
%  as easy to type as possible.  Secondly, we want it as easy to read
%  as possible.  The first means eliminating keystrokes, especially
%  difficult or unusual shifted characters (such as the braces).  The
%  second means as few cryptic control strings as possible.  It is my
%  goal to make it possible to write a simple paper without using a single
%  backslash or brace pair.  (Obviously this is not possible for math
%  papers or other uses for TeXnicalities.)
%
%  Items on the above list that are preceded by an asterisk are not
%  yet coded (/ means unfinished).  If you have an idea that you'd like
%  to see included, please send me email (amgreene@athena.mit.edu); if
%  you write any extensions to this system, please send them to me
%  so I can test them and incorporate them into the definitive
%  distribution. 
%
%  Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Random setup stuff
%
\def\path{/afs/athena/user/a/amgreene/mitex/}
\def\iw{\immediate\write16}
\def\MITeX{{\it MIT}\kern-.1667em \lower.5ex\hbox{E}\kern-.125em X}
\def\gobble#1{}
\catcode`\@=11

\input\path setup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Deal with verbatim (needs reworking)                          Verbatim
%
\catcode`\"=13
\begingroup
\catcode`\&=12\catcode`\%=12\catcode`\{=12\catcode`\}=12\catcode`\/=12
\catcode`\~=12\catcode`\[=12\catcode`\]=12
\catcode`<=1\catcode`\>=2\catcode`\+=0
+gdef"<+begingroup+tt+catcode`+&=12+catcode`+%=12+catcode`+{=12+catcode`+}=12
\catcode`\~=12\catcode`\[=12\catcode`\]=12
\catcode`\/=12+catcode31=1+catcode`+\=12+relax+verb>
+gdef+verb#1"<#1+endgroup>
+endgroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Backslash parser                                              Backslash
%
\def\st@rtcs{\def\w@rd{}%
\catcode32=12\futurelet\nextt@k\startsc@ncs} % catcode is a kludge
%
\def\startsc@ncs{\catcode32=10%
\begingroup\expandafter\ifcat\noexpand\nextt@k A\aftergroup\sc@ncs\else\aftergroup\singlech@rcs\fi\endgroup}
%
\def\singlech@rcs{\begingroup\verbc@tcodes\singlech@rcstwo}
\def\singlech@rcstwo#1{\edef\t@mp{\string #1}\expandafter\aftergroup\csname\t@mp\endcsname\endgroup}
\begingroup\catcode`\#=12
\gdef\verbc@tcodes{%
\catcode`\\=12\catcode`\$
=12\catcode32=12\catcode13=12%
\catcode`\^=12\catcode`\|=12\catcode`\#=12\catcode`\.=12%
\catcode`\/=12\catcode`\*=12\catcode`\_=12\catcode`\&=12%
\catcode`\{=12\catcode`\}=12\catcode`\"=12\catcode`\%=12%
\endgroup
%
\def\sc@ncs{\begingroup%
\ifcat A\nextt@k\aftergroup\@ddtocs\else\aftergroup\sc@ncsend\fi
\endgroup}
%
\def\@ddtocs#1{\edef\w@rd{\w@rd #1}%
\futurelet\nextt@k\sc@ncs}%
%
\def\sc@ncsend{\begingroup
\expandafter\ifx\csname\w@rd\endcsname\relax
\aftergroup\cserr@r\else
\aftergroup\exp@ndcs\fi\endgroup}
%
\def\cserr@r{%
\errh@ndle{MITeX error: Unknown backslash command (\w@rd) encountered.}%
{\iw{MITeX doesn't know the command you gave.}%
\iw{Maybe you misspelled it?}}}
%
\def\exp@ndcs{\csname!!\w@rd\endcsname}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Prologue parser                                                Prologue
%
\def\getw@rd{\def\w@rd{}%
\futurelet\nextt@k\addtow@rd}
%
\def\nl{\relax}
\newtoks\testt@k
\begingroup
\catcode13=13\let^^M=\nl%
\gdef\addtow@rd{%
\begingroup%
\ifx^^M\nextt@k\aftergroup\f@llline\relax%
\else\ifx=\nextt@k\relax\aftergroup\equ@ls\relax%
\else\ifx:\nextt@k\relax\aftergroup\c@lon\relax%
\else\aftergroup\g@bbletow@rd\relax%
\fi\fi\fi\endgroup}%
%
\gdef\equ@ls=#1
{%\iw{equ@ls}%
\expandafter\gdef\csname\w@rd\endcsname{#1}\getw@rd}
%
\gdef\f@llline#1{%\iw{f@llline: \w@rd}%  the #1 swallows the newline
\p@rsedfalse\csname @@\w@rd\endcsname%
\begingroup%
\ifp@rsed\ifpr@logue%
\aftergroup\g@tw@rd
\else\aftergroup\b@gin\fi
\else\aftergroup\c@uldntparse\fi\endgroup}
%
\gdef\g@tw@rd{\futurelet\nextt@k\getw@rd}
%
\gdef\c@lon:{%  for fullines that take parameters
}
%
\gdef\g@bbletow@rd#1{\xdef\w@rd{\w@rd #1}%
%\iw{\w@rd}%
\futurelet\nextt@k\addtow@rd}
%
\endgroup
%
\def\c@uldntparse{%
\errh@ndle{MITeX Error:  Unknown Command (\w@rd) in Prologue}%
{\iw{The prologue contained a command that MITeX doesn't know.}%
\iw{Maybe you misspelled it?}}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Prologue commands                                     Prologue commands
%
\newif\ifp@rsed
\newif\ifpr@logue
%
{\catcode13=13%
\gdef\@@begin{\catcode13=5\p@rsedtrue\pr@loguefalse}%
\gdef\@@debugging{\tracingcommands=2\tracingmacros=2}%
\expandafter\gdef\csname @@10pt\endcsname{\pt{100}}%
\expandafter\gdef\csname @@11pt\endcsname{\pt{110}}%
\expandafter\gdef\csname @@12pt\endcsname{\pt{120}}%
\gdef\@@lettersections{\lettertrue}%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Start the prologue parsing
%
\gdef\beginparse{\let^^M=\nl%
\pr@loguetrue%
\catcode`\$=12%
\catcode`\&=12%
\catcode`\#=12%
\catcode`\^=12%
\catcode`\_=12%
\catcode`\%=12%  the comments are catcode-frozen on input.
\getw@rd}
\catcode13=5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  End of prologue
%
\def\b@gin{%
\dimen255=\leftmargin \advance\dimen255 by -1in \hoffset=\dimen255
\dimen255=8.5in \advance\dimen255 by -\rightmargin 
\advance\dimen255 by -\leftmargin \hsize=\dimen255
\dimen255=\topmargin \advance\dimen255 by -1in \voffset=\dimen255
\dimen255=11in \advance\dimen255 by -\bottommargin 
\advance\dimen255 by -\topmargin \vsize=\dimen255
%
\expandafter\ifx\csname title\endcsname\relax\else
\centerline{\bf\largest\title}\medskip\fi
\expandafter\ifx\csname author\endcsname\relax\else
\centerline{\rm\larger\author}\bigskip\fi
\noindent}
%%%%%%
\input\path fonts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Error Handler                                               Error Handler
%
\def\ir{\read-1 to }
\def\errh@ndle#1#2{\iw{}\iw{#1}
\def\errh@lp{#2}
\errwh@tnow}
%
\def\errwh@tnow{\iw{}\message{What now? }
\ir\errr@ply
\expandafter\p@rsereply\errr@ply
}
%
\def\p@rsereply#1#2
{\edef\t@mp{#1}
\if H\t@mp\errh@lp \else
\if h\t@mp\errh@lp \else
\if X\t@mp \else
\if x\t@mp \else
\if C\t@mp \else
\if c\t@mp \else
\iw{}
\iw{MITeX has tripped over an error, and is waiting for further instructions.}
\iw{}
\iw{Type H for more help, X to exit, or C to continue.}
\fi\fi\fi\fi\fi\fi
\begingroup
\if X\t@mp\end\else
\if x\t@mp\end\else
\if C\t@mp\aftergroup\errc@ntinue\else
\if c\t@mp\aftergroup\errc@ntinue\else
\aftergroup\errwh@tnow\fi\fi\fi\fi
\endgroup}
%
\def\errc@ntinue{\iw{Continuing to read your file.}}
%
\def\go{\immediate\write16{MITeX format 0.1a (27-Nov-89)}
\catcode13=13\beginparse}
\catcode`\.=13
\def.{\futurelet\nextt@k\d@tted}
%
%  Set up the catcodes for backslash
%
\catcode`\Q=0
Qcatcode`Q\=13
Qlet\=Qst@rtcs
Qcatcode31=0
Qcatcode`QQ=11
%
%  Prepare for real stuff
%
%\everyjob{\go}
\go1=1
