% pri.cls / Proceedings of the Royal Irish Academy 
% v1.0, 13-mar-2002  
% Copyright(C) 2002 Cambridge University Press

% This software may only be used in the preparation of journal articles
% or books or parts of books to be published by the Royal Irish Academy.
% Any other use constitutes an infringement of copyright.

%     based on pri.sty, v0.51, 14-jul-2000
%     based on jfm.sty, v1.2,  14-feb-1994 by Joey Sams
%     based on article.sty by Leslie Lamport for LaTeX version 2.09
%
% incorporating also parts of authordate.sty, by David Rhead, of
% the Cripps Computing Centre (February 1990).

% standard sizes used
% \tiny           5/6
% \scriptsize     7/8
% \indexsize      8/9
% \footnotesize   8/10
% \small          9/10
% \tablebody      9/11
% \abstractsize  10/10
% \normalsize    10/12
% \large         11/13
% \Large         14/18
% \LARGE         17/21 (18/21 in Times)
% \huge          20/25
% \Huge          25/30

\NeedsTeXFormat{LaTeX2e}[1996/06/01]
\ProvidesClass{pri}[2002/03/13 v1.0 Proceedings of the Royal Irish Academy document class]

%
% Journals use two-sided printing.
%
\@twosidetrue
\@mparswitchtrue

\newif\ifCUPmtlplainloaded
\newif\if@referee
\DeclareOption{oneside}{\relax}
\DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue}
\DeclareOption{draft}{\setlength\overfullrule{5\p@}}
\DeclareOption{final}{\setlength\overfullrule{\z@}}
\DeclareOption{onecolumn}{\@twocolumnfalse}
\DeclareOption{twocolumn}{\relax}
\DeclareOption{titlepage}{\relax}
\DeclareOption{notitlepage}{\relax}
\DeclareOption{leqno}{\relax}
\DeclareOption{fleqn}{\relax}
\DeclareOption{index}{\@indextrue}
\DeclareOption{prodtf}{\CUPmtlplainloadedtrue}
\DeclareOption{referee}{\@refereetrue}
\ExecuteOptions{twoside,final,onecolumn}
\ProcessOptions\relax

\ifCUPmtlplainloaded\RequirePackage{CUPTimes,pri2esym}\fi

%  ****************************************
%  *               FONTS                  *
%  ****************************************
%
\lineskip 1pt
\normallineskip 1pt
\def\baselinestretch{1}

\renewcommand\normalsize{%                                         10/12
  \@setfontsize\normalsize{10pt}\@xiipt
  \abovedisplayskip 10pt plus 1pt minus 1pt
  \belowdisplayskip \abovedisplayskip
  \abovedisplayshortskip 5pt plus 1pt
  \belowdisplayshortskip  \abovedisplayshortskip
}

\newcommand\small{%                                               9/10
  \@setfontsize\small{9pt}\@xpt
  \abovedisplayskip 8pt plus 1pt minus 1pt
  \belowdisplayskip \abovedisplayskip
  \abovedisplayshortskip 4pt plus 1pt
  \belowdisplayshortskip  \abovedisplayshortskip % SFB 0.96
}

\newcommand\tiny{\@setfontsize\tiny\@vpt{6}}%                       5/6
\newcommand\scriptsize{\@setfontsize\scriptsize\@viipt{8pt}}%       7/8
\newcommand\indexsize{\@setfontsize\indexsize\@viiipt{9pt}}%        8/9
\newcommand\footnotesize{\@setfontsize\footnotesize\@viiipt{10pt}}% 8/10
\newcommand\tablebody{\@setfontsize\tablebody\@ixpt{11pt}}%         9/11
\newcommand\abstractsize{\@setfontsize\abstractsize\@xpt{10pt}}%    10/10
\newcommand\large{\@setfontsize\large\@xipt{13pt}}%                 11/13
\newcommand\Large{\@setfontsize\Large\@xivpt{18pt}}%                14/18
\newcommand\LARGE{\@setfontsize\LARGE\@xviipt{21pt}}%               17/21
\newcommand\huge{\@setfontsize\huge\@xxpt{25pt}}%                   20/25
\newcommand\Huge{\@setfontsize\Huge\@xxvpt{30pt}}%                  25/30

% Make sure that MT typewriter is switched to CM typewriter
% when: 1. OFSS mtclplain is used, 2. NFSS 1/2 `cmtt' style option is used.

\ifx\CUP@mtlplain@loaded\undefined
\else
  \gdef\f@tt{mt} % Monotype Times typewriter default.
%
% Check if `mtclplain' is in use:
%  \ifoldfss \ifx\CUP@cmtt@loaded\undefined \else \gdef\f@tt{cm}\fi \fi
%
% If `cmtt' style option is used:
%  \ifnfssone \ifx\cmtypewriter\undefined \else \gdef\f@tt{cm}\fi \fi
%
% No additional processing is needed for NFSS 2.
\fi

\normalsize

\ifCUPmtlplainloaded\else
  \DeclareTextFontCommand\textsfi{\usefont{OT1}{cmss}{m}{sl}}
  \DeclareMathAlphabet\mathsfi            {OT1}{cmss}{m}{sl}
  \DeclareTextFontCommand\textsfb{\usefont{OT1}{cmss}{bx}{n}}
  \DeclareMathAlphabet\mathsfb            {OT1}{cmss}{bx}{n}
  \DeclareTextFontCommand\textsfbi{\usefont{OT1}{cmss}{m}{sl}}
  \DeclareMathAlphabet\mathsfbi            {OT1}{cmss}{m}{sl}
\fi

%  ****************************************
%  *            PAGE LAYOUT               *
%  ****************************************
%
\if@referee
  \renewcommand\baselinestretch{2}\raggedbottom
\else
  \flushbottom
\fi

% SIDE MARGINS:
\oddsidemargin  2pc
\evensidemargin 2pc
\marginparwidth 2.0cm
\marginparsep 10pt

% VERTICAL SPACING:
\topmargin 2.5pc
\headheight 12pt
\headsep 12pt
\topskip 12pt

\newskip\halflineskip
\halflineskip=6pt plus .5pt minus .5pt
\newskip\affilskip % used by authors to separate affiliations on title page
\affilskip=3pt

% DIMENSION OF TEXT:
\textheight = 45\baselineskip \advance\textheight by \topskip
\textwidth 30pc
\columnsep 10pt
\columnseprule 0pt

% FOOTNOTES:

%%%\setlength\footheight{12pt} %not defined in 2e
\setlength\footskip{24pt}

\setlength\footnotesep{\z@}
\setlength{\skip\footins}{14pt}

% FLOATS:
% \def\topfigrule{\vskip\floatsep\hbox{\rule{\textwidth}{.5pt}}\vskip-%
% \floatsep}
\setlength\floatsep{10pt plus 2pt minus 1pt}
\setlength\textfloatsep{12pt plus 6pt}
\setlength\intextsep{\floatsep}

\setlength\dblfloatsep{\floatsep}
\setlength\dbltextfloatsep{\floatsep}

\setlength\@fptop{0pt plus 0fil}
\setlength\@fpsep{10pt plus 0fil}
\setlength\@fpbot{0pt plus 3fil}
\setlength\@dblfptop{0pt plus 0fil}
\setlength\@dblfpsep{10pt plus 0fil}
\setlength\@dblfpbot{0pt plus 3fil}
\marginparpush 5pt


%  ****************************************
%  *           PARAGRAPHING               *
%  ****************************************
%
\parskip \z@% plus .3pt
\parindent 1.5em
\partopsep 0pt plus 1pt
\@lowpenalty   51
\@medpenalty  151
\@highpenalty 301
\@beginparpenalty -\@lowpenalty
\@endparpenalty -\@lowpenalty
\@itempenalty -\@lowpenalty
\clubpenalty\z@
\widowpenalty\@M

\newif\iffirst@rt

\ifx\CUP@mtlplain@loaded\undefined
  \let\firstarticle\relax
\else
  \font\sixteenrm=mtr10 at 16\p@
  \newcommand\firstarticle{\global\first@rttrue}
  \newcommand\first@rthead{%
    \@ifundefined{epsfbox}{\errmessage{opiepsf must be loaded for the logo}}{}%
    \vspace*{0\p@}\vspace{-7.75\p@}%
    \vbox{{\vbadness10000\hsize\textwidth \centering \normalsize
      {\sixteenrm\baselineskip\z@ PROCEEDINGS}\\[15\p@]
      OF THE\\[12\p@]
      {\sixteenrm\baselineskip\z@ ROYAL IRISH ACADEMY}\\[15.5\p@]
      PAPERS READ BEFORE THE ACADEMY\\[20\p@]
      \centerline{\epsfbox{\opifigpath prilogo1}}%
      \vspace{11.5\p@}%
    }}%
  }
\fi

%  ****************************************
%  *                 PARTS                *
%  ****************************************
%
\def\part{\par \addvspace{4ex}\@afterindentfalse
 \secdef\@part\@spart}
\def\@part[#1]#2{\ifnum \c@secnumdepth >\m@ne
  \refstepcounter{part}
  \addcontentsline{toc}{part}{Part \thepart: #1}
 \else \addcontentsline{toc}{part}{#1}
 \fi
 {\parindent 0pt \centering %changed ggw
  \ifnum \c@secnumdepth >\m@ne
   \reset@font\large\rmfamily PART
   \ifcase\thepart \or ONE \or TWO \or THREE \or FOUR \or FIVE
    \or SIX \or SEVEN \or EIGHT \or NINE \or TEN \else \fi
   \par \nobreak
  \fi
  \reset@font\LARGE\rmfamily #2 \markboth{}{}\par }
 \nobreak \vskip 3ex \@afterheading}
\def\@spart#1{{\parindent 0pt \centering % changed ggw
  \reset@font\LARGE\rmfamily #1\par}
 \nobreak \vskip 3ex \@afterheading}


%  ****************************************
%  *               SECTIONS               *
%  ****************************************
%

\def\@raggedright{\rightskip=\@flushglue \let\\=\@centercr \parindent=0pt}
\def\@raggedcenter{\centering\rightskip=\@flushglue \let\\=\@centercr}

\newif\ifno@eqnreset
\newcommand\nosectioneqnreset{\global\no@eqnresettrue
  \renewcommand\theequation{\@arabic\c@equation}%
}

\def\section{%
  \ifno@eqnreset
    \ifappendix \setcounter{equation}\z@\fi
  \else
    \setcounter{equation}\z@
  \fi
  \@startsection {section}{1}{\z@}
    {-12pt plus -6pt minus -2pt}%    beforeskip; neg = suppress indent
    {6pt}%       afterskip
    {\reset@font\normalsize\bfseries\@raggedcenter}%
}

\def\subsection{\@startsection{subsection}{2}{\z@}
 {-12pt plus -3pt minus -3pt}{0.001pt}
 {\raggedright\reset@font\normalsize\itshape}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}
 {12pt plus 3pt minus 3pt}{-0.5em}
 {\raggedright\reset@font\normalsize\itshape}}
%
\def\paragraph{}
\def\subparagraph{}
%
\def\emptys@t{}
\def\@sect#1#2#3#4#5#6[#7]#8{%
 \ifnum #2>\c@secnumdepth
  \def\@svsec{}%
 \else
  \refstepcounter{#1}%
  \ifnum #2>\@ne
%%%   \edef\@svsec{{\noexpand\reset@font\noexpand\bfseries\csname 
%%%                the#1\endcsname}\hskip 0.5em} % ajw 
     \edef\@svsec{\csname the#1\endcsname.\enskip}%
   \else
                 \def\apphe@d{#8}%
   \edef\@svsec{\ifappendix Appendix \fi\csname the#1\endcsname\relax
                 \ifx \apphe@d\emptys@t
                 \else
                   \ifnum #2=1.\fi
                 \ %
                 \fi
   }%
  \fi
 \fi
 \@tempskipa #5\relax
 \ifdim \@tempskipa>\z@
  \begingroup #6\relax
   \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty \@M #8\par}
  \endgroup
  \csname #1mark\endcsname{#7}%
  \ifnum #2=1% sections only
   \addcontentsline{toc}{#1}{\ifnum #2>\c@secnumdepth \else
    \ifappendix Appendix~\csname the#1\endcsname%
    \else \protect\numberline{\csname the#1\endcsname.}#7\fi
    \fi}
%     \protect\numberline{\csname the#1\endcsname.}\ifappendix\else #7\fi\fi}
  \else
   \addcontentsline{toc}{#1}{\ifnum #2>\c@secnumdepth \else
      \protect\numberline{\csname the#1\endcsname.}#7\fi}
  \fi
 \else %
  \def\@svsechd{#6\hskip #3\@svsec #8\csname #1mark\endcsname {#7}
    \addcontentsline{toc}{#1}{\ifnum #2>\c@secnumdepth \else
     \protect\numberline{\csname the#1\endcsname.}
    \fi#7}}%
 \fi
 \@xsect{#5}}

\newif\ifappendix \appendixfalse
\def\appendix{\par
 \setcounter{section}{0}
 \def\theequation{\Alph{section}\,\arabic{equation}} % (MAW)
%\def\thesection{Appendix \Alph{section}}
 \def\thesection{\Alph{section}}
 \def\thesubsection{\thesection.\arabic{subsection}}
 \def\thesubsubsection{\thesubsection.\arabic{subsubsection}}
 \appendixtrue}

\setcounter{secnumdepth}{2}


%  ****************************************
%  *       PART & SECTION NUMBERS       *
%  ****************************************
%
\newcounter{part}
\newcounter {section}
\newcounter {subsection}[section]
\newcounter {subsubsection}[subsection]
\newcounter {paragraph}[subsubsection]
%\newcounter {subparagraph}[paragraph]
\def\thepart          {\arabic{part}}
\def\thesection       {\arabic{section}}
\def\thesubsection    {\thesection.\arabic{subsection}}
\def\thesubsubsection {\thesubsection.\arabic{subsubsection}}
\def\theparagraph     {\thesubsubsection.\arabic{paragraph}}
%\def\thesubparagraph  {\theparagraph.\arabic{subparagraph}}


%  ****************************************
%  *               SKIPS                  *
%  ****************************************
%
\newskip\@indentskip
\newskip\smallindent
\newskip\@footindent
\newskip\@leftskip
\@indentskip=2.5em
\smallindent=1em
\@footindent=\smallindent
\@leftskip=\z@


%  ****************************************
%  *                LISTS                 *
%  ****************************************
%
\leftmargini\z@
\labelsep\z@
\labelwidth\z@
%
% label macros for Range-Left and Range-Right labels
%\def\makeRLlabel#1{\rlap{#1}\hss}
%\def\makeRRlabel#1{\hss\llap{#1}}
\def\makeitemlabel#1{\hspace\labelwidth\hspace\labelsep\hfill #1}
%
% set leftmargin to labelwidth + labelsep of OUTER list:
\def\@listI{\parsep\z@ \topsep\z@ \partopsep\z@ \itemsep\z@ \rightmargin\z@
 \leftmargin\labelwidth \advance\leftmargin\labelsep}
\def\@listi{\@listI \leftmargin\leftmargini \itemindent 1em}
\def\@listii{\@listI \advance\leftmargin 1em}
\def\@listiii{\@listI}
\def\@listiv{\@listI}
\def\@listv{\@listI}
\def\@listvi{\@listI}
\@listi
%
% ITEMIZE
\def\itemize{\ifnum \@itemdepth >3 \@toodeep
 \else \advance\@itemdepth \@ne
  \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
  \list{\csname\@itemitem\endcsname}%
%  {\labelsep .5em \settowidth{\labelwidth}{\csname\@itemitem\endcsname}
   {\labelsep .5em \leftmargin 3.2em\itemindent-1em\listparindent\parindent
    \let\makelabel\makeitemlabel}%
 \fi}
\def\labelitemi{$\bullet$} % ggw
\def\labelitemii{$\circ$}
\def\labelitemiii{---} % ggw
\def\labelitemiv{--} % ggw
%
% ENUMERATE

\def\makeRRenumlabel#1{\hss\llap{{\reset@font\rmfamily #1}}}%\reset@font\rmfamily 
\def\enumerate{\ifnum \@enumdepth >3 \@toodeep \else
  \advance\@enumdepth \@ne
  \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
 \fi
 \@ifnextchar [{\@enumeratetwo}{\@enumerateone}%
}

\def\@enumerateone{%\listsize
 \list{\csname label\@enumctr\endcsname}%
  {\usecounter{\@enumctr}%
   \leftmargin 3.2em%
   \labelsep 0.5em%
   \itemindent \z@
   \listparindent\parindent
   \let\makelabel\makeRRenumlabel}}

\def\@enumeratetwo[#1]{%\listsize
 \list{\csname label\@enumctr\endcsname}%
  {\settowidth\labelwidth{(#1)}%
   \labelsep 0.5em \itemindent \z@
   \leftmargin\labelwidth \advance\leftmargin\labelsep
   \listparindent\parindent
   \usecounter{\@enumctr}%
   \let\makelabel\makeRRenumlabel}%
}

\def\labelenumi{{\reset@font\rmfamily(}\theenumi{\reset@font\rmfamily)}}
\def\theenumi{{\reset@font\arabic{enumi}}}

\def\labelenumii{{\reset@font\rmfamily(}{\theenumii}{\reset@font\rmfamily)}}
\def\theenumii{{\reset@font\it\alph{enumii}}}
\def\p@enumii{\theenumi.}

\def\labelenumiii{\theenumiii.}
\def\theenumiii{\roman{enumiii}}
\def\p@enumiii{\p@enumii\theenumii.}

\def\labelenumiv{\theenumiv}
\def\theenumiv{\roman{enumiv}}
\def\p@enumiv{\p@enumiii\theenumiii.}

%
% DESCRIPTION
\def\descriptionlabel#1{\hspace\labelsep \reset@font\bfseries #1}
\def\description{\list{}{\labelwidth\z@%\itemindent-\leftmargin
  \ifnum\@listdepth=1\else\advance\leftmargin 1em\fi
  \let\makelabel\descriptionlabel}}
\let\enddescription\endlist


%  ****************************************
%  *            DISPLAYED TEXT            *
%  ****************************************
%
% VERSE
\def\verse{\let\\=\@centercr
 \list{}{\itemsep\z@
  \itemindent -\@indentskip
  \listparindent \itemindent
  \rightmargin\leftmargin
  \advance\leftmargin \@indentskip}\item[]}
\let\endverse\endlist
%
% QUOTATION
\def\quotation{\list{}{\listparindent\smallindent
  \itemindent\listparindent
  \leftmargin\z@\rightmargin\leftmargin
  \topsep\baselineskip
  \parsep 0pt plus 1pt}\item[]\small}
\let\endquotation=\endlist
% QUOTE
\def\quote{\par\list{}{\leftmargin\z@\rightmargin\leftmargin}\item[]%
 \small\rule{0pt}{10pt}\ignorespaces}
\let\endquote=\endlist


%  ****************************************
%  *         OTHER ENVIRONMENTS           *
%  ****************************************
%
% PROOF
\newsavebox{\proofbox}
\sbox{\proofbox}{\rule{6pt}{6pt}}
%\def\proof{\par\noindent{\reset@font\scshape Proof.}\hskip.5em\relax\ignorespaces}

\def\proof{\@ifnextchar[{\proofwith}{\proofwithout}}
\def\proofwith[#1]{\par\addvspace{1\baselineskip plus 1pt}%
   \par\noindent {\reset@font\scshape Proof #1.}%
   \hskip.5em\relax\ignorespaces}
\def\proofwithout{\par\addvspace{1\baselineskip plus 1pt}%
   \par\noindent {\reset@font\scshape Proof.}%
   \hskip.5em\relax\ignorespaces}
\def\endproof{\quad\usebox{\proofbox}\vskip \baselineskip\par}
\@namedef{proof*}{\proof}
\@namedef{endproof*}{\vskip\baselineskip\par}

% THEOREMS

\newif\if@reverse
\def\reversetheorems{\@reversetrue}

\def\newtheorem#1{\@ifnextchar[{\@otheorem{#1}}{\@ntheorem{#1}}}

\def\@ntheorem#1#2{%
\@ifnextchar[{\@xntheorem{#1}{#2}}{\@yntheorem{#1}{#2}}}

\def\@xntheorem#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}\@addtoreset{#1}{#3}%
\expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
  \csname the#3\endcsname \@theoremcountersep \@theoremcounter{#1}}%
\global\@namedef{#1}{\@theorem{#1}{#2}}%
\global\@namedef{#1*}{\@theoremstar{#1}{#2}}%
\global\@namedef{end#1}{\@endtheorem}%
\global\@namedef{end#1*}{\@endtheoremstar}}}

\def\@yntheorem#1#2{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}%
\expandafter\xdef\csname the#1\endcsname{\@theoremcounter{#1}}%
\global\@namedef{#1}{\@theorem{#1}{#2}}%
\global\@namedef{#1*}{\@theoremstar{#1}{#2}}%
\global\@namedef{end#1}{\@endtheorem}%
\global\@namedef{end#1*}{\@endtheoremstar}}}

\def\@otheorem#1[#2]#3{\expandafter\@ifdefinable\csname #1\endcsname
  {\global\@namedef{the#1}{\@nameuse{the#2}}%
\global\@namedef{#1}{\@theorem{#2}{#3}}%
\global\@namedef{#1*}{\@theoremstar{#2}{#3}}%
\global\@namedef{end#1}{\@endtheorem}%
\global\@namedef{end#1*}{\@endtheoremstar}}}

\def\@theorem#1#2{\refstepcounter
    {#1}\@ifnextchar[{\@ytheorem{#1}{#2}}{\@xtheorem{#1}{#2}}}

\def\@xtheorem#1#2{\@begintheorem{#2}%
{\csname the#1\endcsname}\ignorespaces}%
\def\@ytheorem#1#2[#3]{\@opargbegintheorem{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

\newif\ifrembrks
\newcommand\removebrackets{\rembrkstrue}

\def\@begintheorem#1#2{%
  \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}% ajw 
  \if@reverse
    \item[{\reset@font\bfseries #2. #1.}]
  \else
    \item[{\reset@font\bfseries #1\ #2.}]
  \fi
  \reset@font\itshape}%

\def\@opargbegintheorem#1#2#3{%
 \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}% ajw
 \item[{\reset@font\bfseries #1\ #2\ {\reset@font\rmfamily
   \ifrembrks #3\global\rembrksfalse\else (#3)\fi.}}]%
   \reset@font\itshape}

%%%\def\@endtheorem{\endlist\par\@endpefalse}  
\def\@endtheorem{\endlist}%  ajw
\def\@theoremcounter#1{\noexpand\arabic{#1}}
\def\@theoremcountersep{.}
%
%
\def\@theoremstar#1#2{%\refstepcounter{#1}%
\@ifnextchar[{\@ytheoremstar{#1}{#2}}{\@xtheoremstar{#1}{#2}}}

\def\@xtheoremstar#1#2{\@begintheoremstar{#2}%
{\csname the#1\endcsname}\ignorespaces}%
\def\@ytheoremstar#1#2[#3]{\@opargbegintheoremstar{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

%DEFAULT VALUES
\def\@theoremstarcounter#1{{}}
\def\@theoremstarcountersep{{}}
\def\@begintheoremstar#1#2{%
  \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}%ajw
  \item[{\reset@font\bfseries #1.}]\reset@font\itshape}

\def\@opargbegintheoremstar#1#2#3{%
 \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}% ajw
 \item[\hskip \labelsep{\reset@font\bfseries #1\ {\reset@font\rmfamily
   \ifrembrks #3\global\rembrksfalse\else (#3)\fi.}}]%
   \reset@font\itshape}

%%%\def\@endtheoremstar{\endlist\par\@endpefalse}  
\def\@endtheoremstar{\endlist}%  ajw

% DEFINITIONS, exactly as theorems except in roman

\def\newdefinition#1{\@ifnextchar[{\@odefinition{#1}}{\@ndefinition{#1}}}

\def\@ndefinition#1#2{%
\@ifnextchar[{\@xndefinition{#1}{#2}}{\@yndefinition{#1}{#2}}}

\def\@xndefinition#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}\@addtoreset{#1}{#3}%
\expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
  \csname the#3\endcsname \@definitioncountersep \@definitioncounter{#1}}%
\global\@namedef{#1}{\@definition{#1}{#2}}%
\global\@namedef{#1*}{\@definitionstar{#1}{#2}}%
\global\@namedef{end#1}{\@enddefinition}%
\global\@namedef{end#1*}{\@enddefinitionstar}}}

\def\@yndefinition#1#2{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}%
\expandafter\xdef\csname the#1\endcsname{\@definitioncounter{#1}}%
\global\@namedef{#1}{\@definition{#1}{#2}}%
\global\@namedef{#1*}{\@definitionstar{#1}{#2}}%
\global\@namedef{end#1}{\@enddefinition}%
\global\@namedef{end#1*}{\@enddefinitionstar}}}

\def\@odefinition#1[#2]#3{\expandafter\@ifdefinable\csname #1\endcsname
  {\global\@namedef{the#1}{\@nameuse{the#2}}%
\global\@namedef{#1}{\@definition{#2}{#3}}%
\global\@namedef{#1*}{\@definitionstar{#2}{#3}}%
\global\@namedef{end#1}{\@enddefinition}%
\global\@namedef{end#1*}{\@enddefinitionstar}}}

\def\@definition#1#2{\refstepcounter
    {#1}\@ifnextchar[{\@ydefinition{#1}{#2}}{\@xdefinition{#1}{#2}}}

\def\@xdefinition#1#2{\@begindefinition{#2}%
{\csname the#1\endcsname}\ignorespaces}%
\def\@ydefinition#1#2[#3]{\@opargbegindefinition{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

\def\@begindefinition#1#2{%
  \list{}{%
    \topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
   \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel
  }% ajw 
%% \item[{\reset@font\bfseries #1\ #2.}]\reset@font\rmfamily}%
  \if@reverse
    \item[{\reset@font\bfseries #2. #1.}]
  \else
    \item[{\reset@font\bfseries #1\ #2.}]
  \fi
  \reset@font\rmfamily%
}

\def\@opargbegindefinition#1#2#3{%
 \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}% ajw
 \item[{\reset@font\bfseries #1\ #2\ {\reset@font\rmfamily
   \ifrembrks #3\global\rembrksfalse\else (#3)\fi.}}]%
   \reset@font\rmfamily}

%%%\def\@enddefinition{\endlist\par\@endpefalse}  
\def\@enddefinition{\endlist}%  ajw
\def\@definitioncounter#1{\noexpand\arabic{#1}}
\def\@definitioncountersep{.}
%
%
\def\@definitionstar#1#2{%\refstepcounter{#1}%
\@ifnextchar[{\@ydefinitionstar{#1}{#2}}{\@xdefinitionstar{#1}{#2}}}

\def\@xdefinitionstar#1#2{\@begindefinitionstar{#2}%
{\csname the#1\endcsname}\ignorespaces}%
\def\@ydefinitionstar#1#2[#3]{\@opargbegindefinitionstar{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

%DEFAULT VALUES
\def\@definitionstarcounter#1{{}}
\def\@definitionstarcountersep{{}}
\def\@begindefinitionstar#1#2{%
  \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}%ajw
  \item[{\reset@font\bfseries #1.}]\reset@font\rmfamily}

\def\@opargbegindefinitionstar#1#2#3{%
 \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}% ajw
 \item[\hskip \labelsep{\reset@font\bfseries #1\ {\reset@font\rmfamily
   \ifrembrks #3\global\rembrksfalse\else (#3)\fi.}}]%
   \reset@font\rmfamily}

%%%\def\@enddefinitionstar{\endlist\par\@endpefalse} 
\def\@enddefinitionstar{\endlist}%  ajw

% NUMBERED/UNNUMBERED REMARKS
\def\newremark#1{\@ifnextchar[{\@oremark{#1}}{\@nremark{#1}}}

\def\@nremark#1#2{%
\@ifnextchar[{\@xnremark{#1}{#2}}{\@ynremark{#1}{#2}}}

\def\@xnremark#1#2[#3]{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}\@addtoreset{#1}{#3}%
\expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
  \csname the#3\endcsname \@remarkcountersep \@remarkcounter{#1}}%
\global\@namedef{#1}{\@remark{#1}{#2}}%
\global\@namedef{#1*}{\@remarkstar{#1}{#2}}%
\global\@namedef{end#1}{\@endremark}%
\global\@namedef{end#1*}{\@endremarkstar}}}

\def\@ynremark#1#2{\expandafter\@ifdefinable\csname #1\endcsname
{\@definecounter{#1}%
\expandafter\xdef\csname the#1\endcsname{\@remarkcounter{#1}}%
\global\@namedef{#1}{\@remark{#1}{#2}}%
\global\@namedef{#1*}{\@remarkstar{#1}{#2}}%
\global\@namedef{end#1}{\@endremark}%
\global\@namedef{end#1*}{\@endremarkstar}}}

\def\@oremark#1[#2]#3{\expandafter\@ifdefinable\csname #1\endcsname
  {\global\@namedef{the#1}{\@nameuse{the#2}}%
\global\@namedef{#1}{\@remark{#2}{#3}}%
\global\@namedef{#1*}{\@remarkstar{#2}{#3}}%
\global\@namedef{end#1}{\@endremark}
\global\@namedef{end#1*}{\@endremarkstar}}}

\def\@remark#1#2{\refstepcounter
    {#1}\@ifnextchar[{\@yremark{#1}{#2}}{\@xremark{#1}{#2}}}

\def\@xremark#1#2{\@beginremark{#2}%
{\csname the#1\endcsname}\ignorespaces}
\def\@yremark#1#2[#3]{\@opargbeginremark{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

\def\@beginremark#1#2{%
  \list{}{%
    \topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
    \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel
  }%ajw 
%%  \item[{\reset@font\itshape #1\ #2.}]%
  \if@reverse
    \item[{\reset@font\itshape #2. #1.}]
  \else
    \item[{\reset@font\itshape #1\ #2.}]
  \fi
}

\def\@opargbeginremark#1#2#3{%
 \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}%  ajw
 \item[\hskip \labelsep{\reset@font\itshape #1\ #2\ {\reset@font\rmfamily
   \ifrembrks #3\global\rembrksfalse\else (#3)\fi.}}]}

%%%\def\@endremark{\endlist\par\@endpefalse}
\def\@endremark{\endlist}%  ajw
\def\@remarkcounter#1{\noexpand\arabic{#1}}
\def\@remarkcountersep{.}
%
%
\def\@remarkstar#1#2{%\refstepcounter{#1}%
\@ifnextchar[{\@yremarkstar{#1}{#2}}{\@xremarkstar{#1}{#2}}}

\def\@xremarkstar#1#2{\@beginremarkstar{#2}%
{\csname the#1\endcsname}\ignorespaces}
\def\@yremarkstar#1#2[#3]{\@opargbeginremarkstar{#2}{\csname
       the#1\endcsname}{#3}\ignorespaces}

%DEFAULT VALUES
\def\@remarkstarcounter#1{{}}
\def\@remarkstarcountersep{{}}
\def\@beginremarkstar#1#2{%
  \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}%  ajw
  \item[{\reset@font\itshape #1.}]}

\def\@opargbeginremarkstar#1#2#3{%
 \list{}{\topsep 1\baselineskip plus 1pt\labelwidth\z@ \itemindent\z@
 \listparindent\parindent\labelsep .5em\let\makelabel\makeitemlabel}%  ajw
 \item[\hskip \labelsep{\reset@font\itshape #1\ {\reset@font\rmfamily
   \ifrembrks #3\global\rembrksfalse\else (#3)\fi.}}]}

%%%\def\@endremarkstar{\endlist\par\@endpefalse}       
\def\@endremarkstar{\endlist}%  ajw

% EQUATION and EQNARRAY
%
\def\theequation{\thesection.\arabic{equation}}

% subeqn.sty follows
% Copyright (c) 1990 by Stephen Gildea
% Permission to copy all or part of this work is granted, provided
% that the copies are not made or distributed for resale, and that
% the copyright notice and this notice are retained.

\newtoks\@stequation

\def\subequations{\refstepcounter{equation}%
  \edef\@savedequation{\the\c@equation}%
  \@stequation=\expandafter{\theequation}%   %only want \theequation
  \edef\@savedtheequation{\the\@stequation}% % expanded once
  \edef\oldtheequation{\theequation}%
  \setcounter{equation}{0}%
  \def\theequation{\oldtheequation{\textit{\alph{equation}}}}}

\def\endsubequations{\setcounter{equation}{\@savedequation}%
  \@stequation=\expandafter{\@savedtheequation}%
  \edef\theequation{\the\@stequation}\global\@ignoretrue}

% subeqnarray.sty
% Copyright (C) 1988 by Johannes Braams, Dr Neher Laboratories

\newcounter{subequation}[equation]
\def\thesubequation{\theequation{\itshape\@alph\c@subequation}}
%  \@subeqnnum: Produces the equation number for the
%     subeqnarray environment.  The following definition is for
%     flushright numbers; for flushleft numbers, see leqno.doc.
%     The {\reset@font\rmfamily ... } puts the subequation number in 
%     italic type even if an subeqnarray environment appears in 
%     an roman environment.
%
\def\@subeqnnum{{\reset@font\rmfamily (\thesubequation)}} 
%
%    A new label command to refer to subequations. It works
%    like the \label command and was taken from LaTeX.TeX
%
%  \slabel{FOO} then writes the following on file \@auxout :
%        \newlabel{FOO}{{eval(\@currentlabel)}{eval(\thepage)}}
%
\def\slabel#1{\@bsphack\if@filesw {\let\thepage\relax
   \xdef\@gtempa{\write\@auxout{\string
      \newlabel{#1}{{\thesubequation}{\thepage}}}}}\@gtempa
   \if@nobreak \ifvmode\nobreak\fi\fi\fi\@esphack}
%
%    Here's the subeqnarray environment,
%        it steps the equation counter,
%        sets the subequation counter equal to 1
%        and behaves much like the eqnarray environment.
%
% changed to remove space either side of alignment
\def\subeqnarray{\stepcounter{equation}
\let\@currentlabel=\theequation\global\c@subequation\@ne
\global\@eqnswtrue
\global\@eqcnt\z@\tabskip\@centering\let\\=\@subeqncr
$$\halign to \displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne
%  \hskip 2\arraycolsep \hfil${##}$\hfil
   \hfil${\;##\;}$\hfil
%  &\global\@eqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil
  &\global\@eqcnt\tw@ $\displaystyle\tabskip\z@{##}$\hfil % ajw
  \tabskip\@centering&\llap{##}\tabskip\z@\cr}

\def\endsubeqnarray{\@@subeqncr\egroup
                     $$\global\@ignoretrue}

\def\@subeqncr{{\ifnum0=`}\fi\@ifstar{\global\@eqpen\@M
    \@ysubeqncr}{\global\@eqpen\interdisplaylinepenalty \@ysubeqncr}}

\def\@ysubeqncr{\@ifnextchar [{\@xsubeqncr}{\@xsubeqncr[\z@]}}

\def\@xsubeqncr[#1]{\ifnum0=`{\fi}\@@subeqncr
   \noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}}

\def\@@subeqncr{\let\@tempa\relax
    \ifcase\@eqcnt \def\@tempa{& & &}\or \def\@tempa{& &}
      \else \def\@tempa{&}\fi
     \@tempa \if@eqnsw\@subeqnnum\refstepcounter{subequation}\fi
     \global\@eqnswtrue\global\@eqcnt\z@\cr}

% Here's the subeqnarray* environment:

\let\@ssubeqncr=\@subeqncr
\@namedef{subeqnarray*}{\def\@subeqncr{\nonumber\@ssubeqncr}\subeqnarray}
\@namedef{endsubeqnarray*}{\global\advance\c@equation\m@ne%
                           \nonumber\endsubeqnarray}

% \jot = 3pt      % Extra space added between lines of an eqnarray  
%                   environment
% The macro \@eqnnum defines how equation numbers are to appear in equations.
% \def\@eqnnum{(\theequation)}  % (the default in LaTeX)
%
% The following substitution causes \eqnarray to give same spacing
% around =,>,<, etc. as in one-line equation.
\def\eqnarray{\stepcounter{equation}\let\@currentlabel=\theequation
\global\@eqnswtrue
\global\@eqcnt\z@\tabskip\@centering\let\\=\@eqncr
$$\halign to \displaywidth\bgroup\@eqnsel\hskip\@centering
  $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne
% \hskip 2\arraycolsep \hfil${##}$\hfil
  \hfil${\;##\;}$\hfil
% &\global\@eqcnt\tw@ \hskip 2\arraycolsep $\displaystyle\tabskip\z@{##}$\hfil 
  &\global\@eqcnt\tw@ $\displaystyle\tabskip\z@{##}$\hfil 
   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
%
% TITLEPAGE
\def\titlepage{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
  \else \newpage \fi \thispagestyle{titlepage}\c@page\z@}
\def\endtitlepage{\if@restonecol\twocolumn \else \newpage \fi}
\arraycolsep 5pt
\tabcolsep 3pt % this is half the space between cols. in a tabular env. ggw
\arrayrulewidth .5pt
\doublerulesep 1.5pt
\tabbingsep \labelsep
%\skip\@mpfootins = \skip\footins
\skip\@mpfootins = -2pt plus .4pt minus .4pt
\fboxsep = 3pt
\fboxrule = .5pt


%  ****************************************
%  *         TITLE AND ABSTRACT           *
%  ****************************************
%
\def\affiliation#1{\gdef\@affiliation{#1}}
\gdef\@affiliation{}

\newif\if@communicated
\def\communicated#1{\@communicatedtrue\def\@communicated{#1}}
\gdef\@communicated{}

\newcommand\email[1]{\global\@emailtrue
  \def\em@il{$^*$E-mail:~#1}}
\gdef\em@il{}

\newcommand\corresponding[1]{\global\@corresponding@authortrue
  \def\corresponding@author{$^*$Corresponding author, e-mail:~#1}}
\gdef\corresponding@author{}

\def\titlefootnote#1{\global\title@page@footnotetrue
  \def\title@footnote{#1}}
\gdef\title@footnote{}

\newif\if@email
\newif\if@corresponding@author
\newif\iftitle@page@footnote

\def\maketitle{%
  \global\title@pagetrue
%  \iftitle@page@footnote
%    \global\title@page@footnotefalse
%  \fi
  \appendixfalse\@ifnextchar [{\m@ketitleone}{\m@ketitletwo}%
}
\def\m@ketitletwo{\m@ketitleone[n]}
\def\m@ketitleone[#1]{\par
 \begingroup
% no changes to footnoting necessary in EJM; keep at bottom of page -- jas
% \def\thefootnote{\fnsymbol{footnote}}
% \def\@makefnmark{\hbox to 0pt{${\@thefnmark}$\hss}}% fnmark now on line -- ggw
% \bgroup
%  \let\footnote\titlefootnote
%  \def\@makefntext##1{\hskip .5em\@thefnmark \ ##1}
  \newpage \global\@topnum\z@
  \@maketitle{#1}\thispagestyle{titlepage} \@thanks
 \endgroup
 \setcounter{footnote}{0}
 \let\maketitle\relax \let\@maketitle\relax \gdef\@affiliation{}
 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}

\def\and{\reset@font
  \ifx\CUP@mtlplain@loaded\undefined
    \normalsize\rmfamily
  \fi
  \ignorespaces\par\vspace{.75\baselineskip}and\par\vspace{.75\baselineskip}%
  \reset@font\scshape
}

\newif\iffirstna \firstnatrue
\def\newauthor{\ignorespaces\par
  \iffirstna
    \firstnafalse
    \vspace{.5\baselineskip}
  \else
    \vspace{\baselineskip}
  \fi
  \reset@font\scshape}

\def\titlefootnotetext{\@ifnextchar [{\@xfootnotenext}%
   {\begingroup\let\protect\noexpand
      \xdef\@thefnmark{}\endgroup%\thempfn
      \@footnotetext}}

\def\mynewline{\par\reset@font\rmfamily\normalsize}
\def\@maketitle#1{%
  \iffirst@rt \first@rthead\else \newpage\fi
 \vspace*{0pt}
 {\centering \sloppy
  {\@title\par}%  \reset@font\normalsize\rmfamily 
  \vskip 1\baselineskip plus 2pt minus 1pt
  {\reset@font\normalsize\rmfamily%
     \reset@font\normalsize\scshape {\let\\=\mynewline\relax \@author\par}}%
       \@affiliation\par
  \if@communicated
   \vskip 1\baselineskip plus 2pt minus 1pt%
     {\reset@font\normalsize (Communicated by \@communicated.)\par}%
  \fi
   \vskip 1\baselineskip plus 2pt minus 1pt%
     {\reset@font\indexsize [Received \@date.]}%
  \par}%
  \vskip 0pt plus 2pt minus 1pt
  \setlength\footnotesep{7pt}% local to title pages
  \if@email
    {\let\@makefntext\@makefntextni
    \titlefootnotetext{\em@il}}%
  \fi
  \if@corresponding@author
    {\let\@makefntext\@makefntextni
    \titlefootnotetext{\corresponding@author}}%
  \fi
  \iftitle@page@footnote
    {\let\@makefntext\@makefntextni
    \titlefootnotetext{\title@footnote}}%
  \fi
}

\def\abstract{\par\section*{{\reset@font\scshape Abstract}}%
  \reset@font\abstractsize\ignorespaces\parindent=1em}
\def\endabstract{\par\vskip 9pt plus 1pt minus 1pt}


%  ****************************************
%  *            PAGE STYLES               *
%  ****************************************
%
\mark{{}{}}
\gdef\@author{\mbox{}} % SFB 0.96

\def\author{%
  \@ifnextchar [{\@authortwo}{\@authorone}}

% make \and a simple 'and' for \@shortauthor
\def\@authortwo[#1]#2{\gdef\@author{#2}\gdef\@shortauthor{#1}}
\def\@authorone#1{\gdef\@author{#1}
 \begingroup\def\and{and}\gdef\@shortauthor{#1}\endgroup}
\def\shortauthor#1{\gdef\@shortauthor{#1}}
\gdef\@shortauthor{}
\gdef\@title{\mbox{}} % SFB 0.96
\def\title{\@ifnextchar [{\@titletwo}{\@titleone}}
\def\@titletwo[#1]#2{\gdef\@title{\uppercase{#2}}\gdef\@shorttitle{#1}}
\def\@titleone#1{\gdef\@title{\uppercase{#1}}\gdef\@shorttitle{#1}}
\def\shorttitle#1{\gdef\@shorttitle{#1}}
\gdef\@shorttitle{}
% SFB 0.96
\def\volume#1{\gdef\@volume{#1}}
\gdef\@volume{xx}
%
\def\no#1{\gdef\@no{#1}}
\gdef\@no{xx}
%
\def\pagerange#1{\gdef\@pagerange{#1}}
\gdef\@pagerange{1--000}
%
\def\pubyear#1{\def\@pubyear{#1}}
\def\@pubyear{19XX}
%
\def\journal#1{\gdef\@journal{#1}}
\gdef\@journal{%
  {\hbox to\hsize{\reset@font\indexsize\textit{Mathematical Proceedings of
     the Royal Irish Academy}, {\reset@font\bfseries \@volume}\ %
     (\@no),~\@pagerange~(\@pubyear) \hfill \copyright\ Royal Irish Academy}}%
}
%
% \ps@empty and \ps@plain defined in LATEX.TEX

\def\proc{Mathematical Proceedings of the Royal Irish Academy}
%
\def\ps@headings{\let\@mkboth\markboth
  \def\@oddhead{\strut\hfill {\scshape\@shortauthor}{\itshape ---\@shorttitle}\hfill \llap{\thepage}}%
  \def\@evenhead{\strut\rlap{\thepage}\hfill \itshape\proc \hfill}%
  \let\@oddfoot\@empty
  \let\@evenfoot\@oddfoot
  \def\sectionmark##1{\markboth{##1}{}}%
  \def\subsectionmark##1{\markright{##1}}%
}

\def\ps@myheadings{\let\@mkboth\@gobbletwo
  \def\@oddhead{\strut\hfill {\itshape\rightmark}\hfill \llap{\thepage}}%
  \def\@evenhead{\strut\rlap{\thepage}\hfill \itshape\leftmark \hfill}%
  \let\@oddfoot\@empty
  \let\@evenfoot\@oddfoot
  \let\sectionmark\@gobble
  \let\subsectionmark\@gobble
}

\def\ps@titlepage{%
  \let\@oddhead\@empty
  \let\@evenhead\@oddhead
  \def\@oddfoot{\@journal}%
  \let\@evenfoot\@oddfoot
  \let\sectionmark\@gobble
  \let\subsectionmark\@gobble
}


%  ****************************************
%  *         TABLE OF CONTENTS, ETC.      *
%  ****************************************
%
\def\@pnumwidth{1.55em}
\def\@tocrmarg {2.55em}
\def\@dotsep{4.5}
\setcounter{tocdepth}{2}

%\@undottedtocline{LEVEL}{INDENT}{NUMWIDTH}{TITLE}{PAGE}
\def\@undottedtocline#1#2#3#4#5{%
  \ifnum #1>\c@tocdepth
  \else
    \vskip \z@ plus .2pt
    {\hangindent #2\relax
      \rightskip \@tocrmarg \parfillskip -\rightskip
      \parindent #2\relax \@afterindenttrue
      \interlinepenalty\@M \leavevmode
%     \@tempdima #3\relax {\reset@font\rmfamily #4}\nobreak \hfill \nobreak
      \@tempdima #3\relax #4\nobreak \hfill \nobreak % Fix NFSS 1 toc bug.
      \hbox to\@pnumwidth{\hfil\reset@font\rmfamily #5}\par
    }
  \fi
} 
\def\tableofcontents{%
  \@restonecolfalse
  \if@twocolumn\@restonecoltrue\onecolumn\fi
  \vskip 4pt plus .5pt
  \centerline{\reset@font\scshape CONTENTS}
  \vskip 3pt
  \@starttoc{toc}
  \if@restonecol\twocolumn\fi \par\vspace{12pt}%
}
%
\def\l@section#1#2{%
  \addpenalty{\@secpenalty}
  \@tempdima 1.5em
  \begingroup
  \parindent \z@ \rightskip \@pnumwidth
  \parfillskip -\@pnumwidth \reset@font\rmfamily \leavevmode
  \advance\leftskip\@tempdima \hskip -\leftskip 
  {\reset@font\bfseries #1}\nobreak\hfil
  \nobreak\hbox to\@pnumwidth{\hss #2}\par 
  \endgroup
}
\def\l@subsection{\@undottedtocline{2}{2.5em}{2.3em}}
\def\l@subsubsection{\@undottedtocline{3}{3.8em}{3.2em}}
%
% The following are irrelevant for EJM -- jas
% \def\l@paragraph{\@undottedtocline{4}{7.0em}{4.1em}}
% \def\l@subparagraph{\@undottedtocline{5}{10em}{5em}}
% \def\listoffigures{\@restonecolfalse
%  \if@twocolumn\@restonecoltrue\onecolumn\fi
%  \section*{List of Figures}% altered -- ggw
%  \@starttoc{lof} \if@restonecol\twocolumn\fi}
% \def\l@figure{\@undottedtocline{1}{1.5em}{2.3em}}
% \def\listoftables{\@restonecolfalse
%  \if@twocolumn\@restonecoltrue\onecolumn\fi
%  \section*{List of Tables}% altered -- ggw
%  \@starttoc{lot} \if@restonecol\twocolumn\fi}
% \let\l@table\l@figure


%  ****************************************
%  *              THE INDEX               *
%  ****************************************
%
\newif\if@restonecol
\def\theindex{\section*{Index} % changed to U&LC -- ggw
 \addcontentsline{toc}{section}{Index}
 \reset@font\footnotesize \parindent\z@ \parskip\z@ plus .1pt\relax
 \let\item\@idxitem}
\def\@idxitem{\par\hangindent 1em}
\def\subitem {\par\hangindent 1em \hspace*{1em}}
\def\subsubitem{\par\hangindent 1em\hspace*{1em}}
\def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
\def\indexspace{\par\vskip\baselineskip \relax}


%  ****************************************
%  *             FOOTNOTES                *
%  ****************************************

\newif\iftitle@page
\def\@makecol{\ifvoid\footins \setbox\@outputbox\box\@cclv
   \else\setbox\@outputbox
     \vbox{\boxmaxdepth \maxdepth
     \unvbox\@cclv\vskip\skip\footins
     \iftitle@page
       \iftitle@page@footnote
         \title@footnoterule
         \global\title@page@footnotefalse
       \else
%%%         \vskip -12pt
         \footnoterule
       \fi
       \global\title@pagefalse
     \else
       \footnoterule
     \fi
     \unvbox\footins}\fi
     \xdef\@freelist{\@freelist\@midlist}\gdef\@midlist{}\@combinefloats
     \setbox\@outputbox\vbox to\@colht{\boxmaxdepth\maxdepth
        \@texttop\dimen@\dp\@outputbox\unvbox\@outputbox
        \vskip-\dimen@\@textbottom}%
     \global\maxdepth\@maxdepth}

\def\footnoterule{\kern-3\p@
  \hrule width \textwidth height \z@ \kern 3\p@}

\def\title@footnoterule{\vskip 12pt\kern-3\p@ 
  \hrule width \textwidth height .25pt \kern 3\p@\vbox to 4pt{}}

%\def\normal@footnoterule{\kern-3\p@ 
%  \hrule width \textwidth height \z@ \kern 3\p@}

%\global\let\footnoterule\normal@footnoterule

\def\@makefnmark{\hbox to 0pt{$^{\@thefnmark}$\hss}}

\long\def\@makefntext#1{\parindent 1em\noindent
  \hbox to 1.5em{\hss$^{\@thefnmark}$}%
  \reset@font\rmfamily #1}

\def\@makefntextni#1{\parindent 1em\noindent \reset@font\rmfamily #1}

\def\thempfootnote{\alph{mpfootnote}}
\def\@makempfnmark{\hbox{$^{\@thefnmark}$}}
%
\long\def\@makempfntext#1{\@setpar{\@@par\@tempdima \hsize
  \advance\@tempdima-\@footindent
  \parshape \@ne \@footindent \@tempdima}\par
  \noindent \hbox to \z@{\hss$^{\@thefnmark}$\hspace{0.5em}}#1} % v.01.10 SFB

\def\@iiiminipage#1#2[#3]#4{%
  \leavevmode
  \@pboxswfalse
  \setlength\@tempdima{#4}%
  \def\@mpargs{{#1}{#2}[#3]{#4}}%
  \setbox\@tempboxa\vbox\bgroup
    \color@begingroup
      \hsize\@tempdima
      \textwidth\hsize \columnwidth\hsize
      \@parboxrestore
      \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
      \let\@makefnmark\@makempfnmark % v.01.03 SFB
      \let\@footnotetext\@mpfootnotetext
      \let\@listdepth\@mplistdepth \@mplistdepth\z@
      \@minipagerestore\global\@minipagetrue %% \global added 24 May 89
      \everypar{\global\@minipagefalse\everypar{}}}
 \let\@minipagerestore=\relax

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555

\def\@fnsymbol#1{%
   {^{\@arabic{#1}}\relax}
}

%  ****************************************
%  *         FIGURES AND TABLES           *
%  ****************************************
%
\setcounter{topnumber}{3}
\def\topfraction{.9}
\setcounter{bottomnumber}{0}
\def\bottomfraction{.9}
\setcounter{totalnumber}{3}
\def\textfraction{.1}
\def\floatpagefraction{.9}
\setcounter{dbltopnumber}{3}
\def\dbltopfraction{.9}
\def\dblfloatpagefraction{.5}

\newbox\turnov@width

\long\def\@makecaption#1#2{%
  \vskip 5pt plus .4pt minus .4pt\begingroup\iffig@re\small\vskip 10pt\fi
  \setbox\@tempboxa\hbox{{\reset@font\scshape #1}---#2}%
  \setbox\turnov@width\hbox{{\reset@font\scshape #1}---}%
  \ifdim \wd\@tempboxa >\hsize 
  \list{}{\labelsep\z@\itemindent -\wd\turnov@width\listparindent\parindent
  \leftmargin\wd\turnov@width}\item[{\reset@font\scshape #1}---]#2\endlist
  \else
  {\centering \unhbox\@tempboxa\par} \fi \endgroup}
%
\newcounter{table}
\def\thetable{\@arabic\c@table}
\def\fps@table{tp}
\def\ftype@table{1}
\def\ext@table{lot}
\def\fnum@table{Table~\thetable}

%%\def\table{\@float{table}\reset@font\tablebody}
\def\table{%
  \let\@tabarray\c@tabarray
  \let\@tarray\c@tarray
  \let\@ttarray\c@ttarray
  \let\t@barray\ct@barray 
  \@float{table}\reset@font\tablebody}

\let\endtable\end@float

\@namedef{table*}{\@dblfloat{table}}
\@namedef{endtable*}{\end@dblfloat}
\def\fstyle@table{\reset@font\small\rmfamily}
\def\fjust@table{\centering}%changed ggw
\def\fcapjust@table{\centering} %changed ggw
\def\fcapsize@table{\reset@font\small\scshape}
\def\fcapstyle@table{\reset@font\small\rmfamily}
%
\newcounter{figure}
\newif\iffig@re

\def\thefigure{\@arabic\c@figure}
\def\fps@figure{tp}
\def\ftype@figure{2}
\def\ext@figure{lof}
\def\fnum@figure{Fig.~\thefigure}
\def\figure{\global\fig@retrue\@float{figure}}
\def\endfigure{\end@float\global\fig@refalse}
\@namedef{figure*}{\@dblfloat{figure}}
\@namedef{endfigure*}{\end@dblfloat}
\def\fstyle@figure{\reset@font\small\rmfamily}
\def\fjust@figure{\centering}
\def\fcapjust@figure{\centering}% changed ggw
\def\fcapsize@figure{\reset@font\small\scshape}
\def\fcapstyle@figure{\reset@font\small\rmfamily}
\newif\ifwide@float
\wide@floatfalse
%
%\@caption{TYPE}[STEXT]{TEXT}
\def\@dblfloat{\wide@floattrue\@float}
\def\end@dblfloat{\if@twocolumn\egroup
 \ifnum\@floatpenalty <\z@ \@cons\@dbldeferlist\@currbox\fi
 \ifnum \@floatpenalty =-\@Mii \@esphack\fi\else\end@float\fi
 \wide@floatfalse}

%this is to preserve the old tabular environment in case it is needed
\let \oldtabular \tabular
\let \endoldtabular \endtabular

% these definitions from jfp.sty
\def\tabular{%
  \noindent
  \let\@tabarray\c@tabarray
  \let\@tarray\c@tarray
  \let\@ttarray\c@ttarray
  \let\t@barray\ct@barray 
  \def\@halignto{to \textwidth}%
%  \doublerulesep 1.5pt
  \def\hline{%
    \noalign{\ifnum0=`}\fi
    \vskip 6pt%
    \hrule \@height \arrayrulewidth
%   \hrule width \textwidth \@height \arrayrulewidth
    \vskip 6pt%
    \futurelet \@tempa\@xhline
  }%
  \def\@xhline{%
    \ifx\@tempa\hline
    \vskip -12pt%
    \vskip \doublerulesep
    \fi
    \ifnum0=`{\fi}%
  }%
  \def\@arrayrule{%
    \@addtopreamble{%
      \hskip -.5\arrayrulewidth
%     \vrule \@width \arrayrulewidth
      \hskip .5\arrayrulewidth
    }%
  }%
  \tabskip=\tabcolsep plus 1fil\@tabular
}

\def\c@tabarray{\@ifnextchar[{\@tarray}{\@ttarray}}
\def\c@tarray[#1]#2{\t@barray[#1]{@{\tabskip=2\tabcolsep plus 3pt} #2}}
\def\c@ttarray#1{\t@barray[c]{@{\tabskip=2\tabcolsep plus 3pt} #1}}
\def\ct@barray[#1]#2{%
  \setbox\@arstrutbox=\hbox{%
    \vrule height\arraystretch \ht\strutbox
    depth\arraystretch \dp\strutbox width\z@
  }\@mkpream{#2}\edef\@preamble{%
    \halign \noexpand\@halignto
    \bgroup \tabskip\z@ \@arstrut \@preamble \tabskip=\tabcolsep plus 1fil 
    \cr
  }%
  \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
  \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
  \bgroup \let\par\relax
  \let\@sharp##
  \let\protect\relax \lineskip\z@\baselineskip\z@\@preamble
}

%  ****************************************
%  *           CUP specials               *
%  ****************************************
%
\def\smallls{\kern.12em} % for letterspacing the word AND
\def\ls{\kern.15em} % for letterspacing; .15em is a hair less than thinspace
\def\ns{\kern.5em} % for name-spacing
\renewcommand{\thefootnote}{\mbox{$\fnsymbol{footnote}$}}
\def\hline{\noalign{\ifnum0=`}\fi \vskip 6pt
 \hrule \@height \arrayrulewidth \vskip 6pt
 \futurelet \@tempa\@xhline}
\def\@xhline{\ifx\@tempa\hline \vskip -12pt
 \vskip \doublerulesep \fi \ifnum0=`{\fi}}
%%\newenvironment{acknowledgments}{}{}

\def\acknowledgement{\par\section*{{\reset@font\scshape Acknowledgement}}}
\def\endacknowledgement{\par}

\def\acknowledgements{\par\section*{{\reset@font\scshape Acknowledgements}}}
\def\endacknowledgements{\par}


%  ****************************************
%  *            MISCELLANEOUS             *
%  ****************************************
%
\edef\today{\number\day\ \ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December
 \fi \ \number\year}


%  ****************************************
%  *           BIBLIOGRAPHY               *
%  ****************************************
% the immediately following code is taken from MSCS.sty, somewhat modified.
% \def\@biblabel#1{#1}
\def\@biblabel#1{} % remove label from bibliography listing
\newcounter{dummy}

\def\makeRRlabel#1{\hss\llap{{\reset@font\rmfamily\footnotesize [#1]}}}

\def\thebibliography#1{%
  \reset@font\footnotesize 
  \def\bibname{\def\and{{\reset@font\rmfamily and} }\reset@font\scshape}
  \section*{{\reset@font\scshape References}}%
  \addcontentsline{toc}{section}{References}%
  \list{{\reset@font\rmfamily\footnotesize\arabic{enumi}}}{%
         \setbox\@tempboxa=\hbox{\reset@font\footnotesize\rmfamily[#1]}%
         \labelwidth=\wd\@tempboxa
         \labelsep 4pt%
         \leftmargin 36pt%
         \itemsep 0pt%
         \itemindent \z@ 
           \advance\itemindent -\leftmargin
           \advance\itemindent\labelwidth \advance\itemindent\labelsep
         \usecounter{enumi}%
         \let\makelabel=\makeRRlabel 
}
 \parindent\z@
 \parskip\z@ plus .1pt\relax
 \def\newblock{\hskip .11em plus .33em minus .07em}%
 \sloppy\clubpenalty\z@ \widowpenalty\@M
 \sfcode`\.\@m\relax
}
%
\let\endthebibliography=\endlist
\def\@biblabel#1{\reset@font\bfseries #1\ }

%  ****************************************
%  *                ODDS                  *
%  ****************************************
%
\def\hexnumber#1{\ifcase#1 0\or1\or2\or3\or4\or5\or6\or7\or8\or9\or
  A\or B\or C\or D\or E\or F\fi}

\newif\iffontfound
\newcommand\checkfont[1]{%
  \batchmode
  \font\test=#1\relax
  \errorstopmode
  \fontfoundfalse
  \ifx\test\nullfont \else \fontfoundtrue\fi
}

%  ****************************************
%  *           INITIALIZATION             *
%  ****************************************
%
\ps@headings
\pagenumbering{arabic}
\onecolumn \let\onecolumn=\relax
%\def\twocolumn{\typeout{Two column mode not available with pri style.}}
% We want twocolumn available for reviews, as in the type spec. ggw
\frenchspacing
\flushbottom

\endinput
