\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
%  Make // switch into italics:                                     Italics
%
\let\sl@shedonce=/
\let\it@lcorrect=\/
\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
\newcount\f@@tnotecount\f@@tnotecount=0
\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\global\advance\f@@tnotecount by 1\relax
\begingroup\catcode`\]=13\def]{\futurelet\nextt@k\cl@sebracket}%
\footnote{$^{\the\f@@tnotecount}$}\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{\count255=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\count255 by 1\relax\futurelet\nextt@k\s@ctionhead}
%
\def\curs@ct{1}
\expandafter\def\csname s@ctname1\endcsname{0}
%
\newif\iflettering\letteringfalse
%
\def\s@ctn@me{
\iflettering\count255=\csname s@ctname1\endcsname%
\advance\count255 by 64\relax%
\char\count255\else%
\csname s@ctname1\endcsname%
\count255=1\relax%
\loop%
\advance\count255 by 1\relax%
\ifnum\count255<\curs@ct%
.\csname s@ctname\the\count255\endcsname%
\repeat}
%
\def\s@ction #1\par{%\iw{sec}  % for some reason, the par doesn't terminate
%                                when in ``read from terminal'' mode.
\ifnum\count255>\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\count255 by 1\relax%
\xdef\curs@ct{\the\count255}%
\expandafter\xdef\csname s@ctname\the\count255\endcsname{0}%
\advance\count255 by -1\relax%
\count254=\csname s@ctname\the\count255\endcsname%
\advance\count254 by 1\relax%
\expandafter\xdef\csname s@ctname\the\count255\endcsname{\the\count254}\fi%
% typeset header:
\par\bigskip\noindent{%
\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
