% Document class for the Ascona workshop
% Copyright (C) 1997 by Carsten Steger
% Kenndaten
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{smati97}[1997/02/03 Class for Ascona articles]
% Initialisierungsteil
%\RequirePackage{times}
\RequirePackage{epsfig}
% Deklaration von Optionen
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
% Ausfuehrung von Optionen
\ProcessOptions
% Laden von Paketen
\LoadClass[12pt,a4paper]{article}
% Hauptteil
\setlength{\textwidth}{15cm}
\setlength{\textheight}{22.5cm}
\setlength{\oddsidemargin}{0.5cm}
\setlength{\evensidemargin}{0.5cm}
\setlength{\topmargin}{1cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{0cm}
\setlength{\parindent}{0pt}
\setlength{\parskip}{2pt plus 1pt}
\setcounter{secnumdepth}{2}
\flushbottom
\pagestyle{empty}

\renewcommand{\baselinestretch}{1.0}

\renewcommand{\section}{\@startsection{section}{1}{\z@}{-2.0ex plus-1ex minus
    -.2ex}{1.3ex plus.2ex}{\reset@font\large\bf}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}{-2.0ex plus-1ex
    minus-.2ex}{1.0ex plus.2ex}{\reset@font\bf}}
\renewcommand{\subsubsection}{\@startsection{subsection}{3}{\z@}%
    {0pt plus 3pt}{-1ex}{\reset@font\bf}}

\long\def\@makecaption#1#2{%
   \vskip 10\p@
   \setbox\@tempboxa\hbox{{\small {\bf #1:} #2}}%
   \ifdim \wd\@tempboxa >\hsize
       {\small {\bf #1:} #2}\par
     \else
       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
   \fi}

\renewcommand\maketitle{\par
  \begingroup
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
    \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
    \long\def\@makefntext##1{\parindent 1em\noindent
            \hb@xt@1.8em{%
                \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
    \newpage
    \global\@topnum\z@
    \@maketitle
    \@thanks
  \endgroup
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}
\def\@maketitle{%
  \newpage
  \null
  \vskip 0.8cm%
  \begin{center}%
  \let \footnote \thanks
    {\LARGE\bf \@title \par}%
    \vskip 28pt%
    {\large\bf \@author \par}%
    \vskip 14pt%
    {\normalsize
      \lineskip .5em%
      \begin{tabular}[t]{c}%
        \@affiliation
      \end{tabular}\par}%
  \end{center}%
  \par
  \vskip 28pt}
\def\affiliation#1{\gdef\@affiliation{#1}}
\def\@affiliation{\@latex@warning@no@line{No \noexpand\affiliation given}}

\def\abstract{
\begin{center}%
{\bf \abstractname\vspace{-.4em}\vspace{\z@}}%
\end{center}%
\small}
\def\endabstract{}

\def\fnum@figure{{\bf \figurename}~\thefigure}
\def\fnum@table{{\bf \tablename}~\thetable}
\def\figurename{Fig.}
\def\tablename{Tab.}

\def\@biblabel#1{}
\def\thebibliography#1{\section*{\refname\@mkboth
  {\uppercase{\refname}}{\uppercase{\refname}}}\list
  {\@biblabel{\arabic{enumiv}}}{\settowidth\labelwidth{\@biblabel{#1}}%
    \leftmargin 0pt
    \labelsep 0pt
    %\advance\leftmargin\labelsep
    \usecounter{enumiv}%
    \let\p@enumiv\@empty
    \def\theenumiv{\arabic{enumiv}}}%
    \def\newblock{\hskip .11em plus.33em minus.07em}%
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}
\def\endthebibliography{%
  \def\@noitemerr{\@warning{Empty `thebibliography' environment}}%
  \endlist}

\def\@hiteml[#1]#2#3#4{\item[]\if@filesw%
      { \def\protect##1{\string ##1\space}\immediate%
\write\@auxout{\string\harvardcite{#4}{#2}{#1}{#3}}}\fi%
\protect\hspace*{-\labelwidth}\protect\hspace*{-\labelsep}\ignorespaces}

\def\@hitem#1#2#3{\item[]\if@filesw%
      { \def\protect##1{\string ##1\space}\immediate%
\write\@auxout{\string\harvardcite{#3}{#1}{#1}{#2}}}\fi%
\protect\hspace*{-\labelwidth}\protect\hspace*{-\labelsep}\ignorespaces}

\def\harvarditem{\@ifnextchar [{\@hiteml}{\@hitem}}

\def\harvardcite#1#2#3#4{
  \global\@namedef{bhf@#1}{#2}
  \global\@namedef{bha@#1}{#3}
  \global\@namedef{bhy@#1}{#4}\global\@namedef{b@#1}{\csname bhf@#1\endcsname}
}

\def\cite{\@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}
\def\citeasnoun{\@ifnextchar [{\@tempswatrue\@citexasnoun}
                           {\@tempswafalse\@citexasnoun[]}
}

\def\@enamedef#1{\expandafter\def\csname #1\expandafter\endcsname\expandafter}

\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
  \def\@citea{}\@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{\@hisep\penalty\@m\ }\@ifundefined
       {b@\@citeb}{{\bf ?}\@warning
       {Citation `\@citeb' on page \thepage \space undefined}}%
    {{\csname b@\@citeb\endcsname\@hysep\csname bhy@\@citeb\endcsname}%
    \global\@enamedef{b@\@citeb}{\csname bha@\@citeb\endcsname}}%
    }}{#1}}

\def\@citexasnoun[#1]#2{%
\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi%
\@citeasnoun{{\@ifundefined%
{b@#2}%
{{\bf ?}\@warning{Citation `#2' on page \thepage \space undefined}}%
{{\csname b@#2\endcsname\ (\csname bhy@#2\endcsname}%
\global\@namedef{b@#2}{\csname bha@#2\endcsname}}%
}}{#1}}

\gdef\hysep@agsm{\ }\gdef\hisep@agsm{,}%
\gdef\hysep@dcu{, }\gdef\hisep@dcu{;}%
\let\@hysep\hysep@agsm \let\@hisep\hisep@agsm
\def\citationstyle#1{%
\global\@namedef{@hysep}{\csname hysep@#1\endcsname}%
\global\@namedef{@hisep}{\csname hisep@#1\endcsname}}
 
\def\@cite#1#2{({#1\if@tempswa , #2\fi})}
\def\@citeasnoun#1#2{{#1\if@tempswa , #2\fi)}}

\def\enddocument{\@checkend{document}\clearpage\begingroup
\if@filesw \immediate\closeout\@mainaux
\def\global\@namedef##1##2{}\def\newlabel{\@testdef r}%
\def\bibcite{\@testdef b}%
\def\harvardcite{\@testbibh}\@tempswafalse \makeatletter\input \jobname.aux
\if@tempswa \@warning{Label(s) may have changed.  Rerun to get
cross-references right}\fi\fi\endgroup\deadcycles\z@\@@end}
 
\def\@testbibh #1#2#3{
  \def\@tempa{#2}\expandafter
  \ifx \csname bhf@#1\endcsname \@tempa 
     \def\@tempa{#3}\expandafter
     \ifx \csname bha@#1\endcsname \@tempa
     \else \@tempswatrue
     \fi
  \else
     \@tempswatrue
  \fi
}
