\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
\baselineskip=\footnotebaselineskip\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\nosectionnumbers{\def\s@ctn@me{}}
%
\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\quad}
%
\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
% This should keep page breaks happy, but doesn't:
\vskip0pt plus2\baselineskip\penalty-250
\vskip0pt plus-2\baselineskip
% Now, set the real header
\noindent{\raggedright
\ifnum\curs@ct=2\relax\sectbf\larger % section
\else\ifnum\curs@ct=3\relax\sectbf\large % subsection
\else\ifnum\curs@ct=4\relax\sectbf\normalsize % subsubsection
\else\normalsize\it % even lower....
\fi\fi\fi
\s@ctn@me\ignorespaces #1}%
\par\nobreak\smallskip\nobreak\noindent}
%%%%%%%%%%%%%%%%%%%%%%
\def\sectbf{\bf}
\catcode`\@=\c@tcode
