%%
%%    File : cstechrep.cls    (LaTeX2e class file)
%%  Author : Martin Reddy (mxr@dcs.ed.ac.uk) 
%% Version : 1.0
%% Updates : 1.0 [13/5/96] - initial release.
%%           1.1 [27/5/96] - dropped pandora font for times
%%           1.2 [27/8/96] - made compatible with OzTeX
%%
%% This file contains a class definition, cstechrep, for the LaTeX2e
%% system which defines the layout of technical reports used by the
%% Department of Computer Science at the University of Edinburgh.
%%
%% For information on this class, please refer to "texdoc cstechrep"
%%
%% To Do List:
%%

\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesClass{cstechrep}[1996/05/13 v1.2 CS Technical Report Class - MXR]

%%
%% --- Initial Code ---
%%

\RequirePackage{ifthen}

\newcommand{\csgroup}{}       % holds "csg" or "lfcs" (undef. by default)
\newcommand{\repnumb}{}       % the technical report number (undef. by default)
\newcommand{\pntsize}{}       % the default font size
\newboolean{altfont}          % whether to use alternative font
\newboolean{titlepage}        % whether to produce separate title page
\newboolean{coverpage}        % whether to produce a standard cover page

%%
%%  --- Options ---
%%

\newcommand{\optionerror}[1]
   {\typeout{*** Warning: #1 is not a legal class option}}

\DeclareOption{csg}{\renewcommand{\csgroup}{csg}}
\DeclareOption{lfcs}{\renewcommand{\csgroup}{lfcs}}

\DeclareOption{cm}{\setboolean{altfont}{false}}
\DeclareOption{times}{\setboolean{altfont}{true}}

\DeclareOption{titlepage}{\setboolean{titlepage}{true}}
\DeclareOption{notitlepage}{\setboolean{titlepage}{false}}

\DeclareOption{coverpage}{\setboolean{coverpage}{true}}
\DeclareOption{nocoverpage}{\setboolean{coverpage}{false}}

\DeclareOption{12pt}{\renewcommand{\pntsize}{12pt}}
\DeclareOption{11pt}{\renewcommand{\pntsize}{11pt}}
\DeclareOption{10pt}{\renewcommand{\pntsize}{}}

\DeclareOption{twocolumn}{\OptionNotUsed\optionerror{twocolum}}
\DeclareOption{parskip}{\AtEndOfClass{\input{parskip.clo}}}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

\ExecuteOptions{12pt,notitlepage,nocoverpage,cm}   % the default options
\ProcessOptions

%%
%% --- Class Loading (built ontop of article.cls) ---
%%

\LoadClass[a4paper,\pntsize]{article}

%%
%% --- Package Loading ---
%%

\RequirePackage{a4wide}           % use this for margin settings

%%
%% --- Main Code ---
%%

\renewenvironment{abstract}{}
   {\typeout{Abstract environment not available: use abstract{...} instead}}

%%
%% Check for an alternative font request
%%

\ifthenelse{\boolean{altfont}}
   {\RequirePackage{times}}
   {}

%%
%% Now let's look at the format for the title page of the
%% report. This is done by redefining \maketitle, and allowing
%% some extra input options: \reportnumber, \abstract and \keywords
%% We also redefine author and title with optional args for coverpage
%%

\newcommand{\department}{Department of Computer Science}
\newcommand{\university}{University of Edinburgh}

\renewcommand{\author}[2][]{
   \newcommand{\@author}{#2}
   \ifthenelse{\equal{#1}{}}
   {\newcommand{\@coverauthor}{#2}}
   {\newcommand{\@coverauthor}{#1}}
}
\let\@author\relax
\let\@coverauthor\relax

\renewcommand{\title}[2][]{
   \newcommand{\@title}{#2}
   \ifthenelse{\equal{#1}{}}
   {\newcommand{\@covertitle}{#2}}
   {\newcommand{\@covertitle}{#1}}
}
\let\@title\relax
\let\@covertitle\relax

\def\reportnumber#1{\gdef\@reportnumber{#1}}
\let\@reportnumber\relax

\def\abstract#1{\gdef\@abstract{#1}} 
\let\@abstract\relax
\def\abstractname{Abstract}

\def\keywords#1{\gdef\@keywords{#1}} 
\let\@keywords\relax
\def\keywordsname{Keywords}

\def\@mymaketitle{
  \begin{center}
    {\LARGE\bfseries\@title\par}\vskip 1.5em
    {\large\lineskip .5em
      \begin{tabular}[t]{c}
        \@author \vspace{6pt}\\
        \ifx\@reportnumber\relax\else Technical Report \@reportnumber\\ \fi
        \department\\ \university
      \end{tabular}\par}%
    \vskip 1em%
    {\large \@date}%
  \end{center}%
  \par\vskip 1.5em

  \ifx\@abstract\relax\else
    \ifthenelse{\boolean{titlepage}}
      {\begin{center}\bf\abstractname\end{center}\quotation\noindent\@abstract}
      {\small\quotation\noindent{\bf\abstractname:} \@abstract}
      \ifx\@keywords\relax\else {
        \vskip 1.4ex
        \noindent{\bf \keywordsname:} \@keywords}
      \fi
      \endquotation
  \fi
  \null\par
  }

\def\cleartitlevars{
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}

\ifthenelse{\boolean{titlepage}}{
  \renewcommand{\maketitle}{
    \frontcoverpage
    \begin{titlepage}
      \renewcommand{\thefootnote}{\@fnsymbol\c@footnote}%
      \let\footnotesize\small
      \let\footnote\thanks
      \null\vskip 30\p@
      \@mymaketitle
      \@thanks
      \vfil\null
    \end{titlepage}
    \setcounter{footnote}{0}
    \cleartitlevars
    }
 }{
  \renewcommand{\maketitle}{
    \frontcoverpage
    \par
    \begingroup
    \renewcommand{\thefootnote}{\@fnsymbol\c@footnote}%
%%
%% Removed the following lines for compatibility with OzTex (mxr)
%%
%    \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@   % Prevents figures from going at top of page.
    \let\footnote\thanks
    \@mymaketitle
    \thispagestyle{plain}\@thanks
    \endgroup
    \setcounter{footnote}{0}
    \cleartitlevars
   }}

%%
%% Check for a cover page request
%%

\newcommand{\frontcoverpage}
   {\ifthenelse{\boolean{coverpage}}
    {\ifthenelse{\equal{\csgroup}{csg}}
      {\csgcoverpage}
      {\ifthenelse{\equal{\csgroup}{lfcs}}
       {\lfcscoverpage}
       {\typeout{Must specify "csg" or "lfcs" class option with "coverpage".}}}
    }{}
}

\RequirePackage{cstechrep-covers}   % the front cover for LFCS & CSG reports

%%
%% EOF: cstechrep.cls
%%
