%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simon's Lab Fax Class for 1998
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simon Moore, University of Cambridge, Computer Laboratory
% Please use freely (it's just a hack!)
% Source from: http://www.cl.cam.ac.uk/~swm11/letters/index.html
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Class Options:
%  usecmfont    - uses computer modern font rather than Sabon (works
%                 better with xdvi
%  usetimesfont - uses times font rather than Sabon
%
%  e.g.:
%  \documentclass[usecmfont,usebwarms]{/homes/swm11/texmacros/letters/labfax98}
%
% Compulsory commands:
%  \fromwhome{your name}{email}{phone}{fax}
%  \begin{fax}{their name}{their institution}{their fax number}
%  \end{fax}
%
% Extra commands:
%  \setdate{date string}
%  \totalpages{number of pages}
%
% An example of use is available here:
%   /homes/swm11/texmacros/letters/labfax98eg.tex


% bsed on the article class
\LoadClass[11pt,a4paper]{article}
\ProvidesClass{/homes/swm11/texmacros/letters/labfax98}[1998/03/31]

\typeout{Simon Moore's Computer Lab Fax Class for 1998}

\usepackage{sabon}		  % Univ. font is Sabon!
\renewcommand{\ttdefault}{cmtt}   % but don't use courier for typewriter
\usepackage{color}
\usepackage{graphics}


% page layout
\pagestyle{plain}
\setlength{\oddsidemargin}{20mm}
\setlength{\evensidemargin}{20mm}
    % use -31mm for official skip, -25mm for window envelopes
\setlength{\topmargin}{-25mm}
\setlength{\textwidth}{14cm}
\setlength{\textheight}{265mm}  %235mm if address in footer
%\setlength{\footskip}{25mm}
\parskip 10pt
\parindent 0.0pt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% main content commands
\newcommand{\fromnamedetails}{Use \\from to speficfy your name,
position, email, phone, fax}
\newcommand{\fromquoldetails}{your qualifications?}
\newcommand{\fromjobdetails}{your position?}
\newcommand{\fromemaildetails}{email?}
\newcommand{\fromphonedetails}{phone?}
\newcommand{\fromfaxdetails}{fax?}
\newcommand{\fromwhom}[4]{
	\renewcommand{\fromnamedetails}{#1}
	\renewcommand{\fromemaildetails}{#2}
	\renewcommand{\fromphonedetails}{#3}
	\renewcommand{\fromfaxdetails}{#4}
        }

\newcommand{\tofaxdetails}{Use \\towhom to set the name, institution and fax}
\newcommand{\toinstdetails}{institution?}
\newcommand{\towhomname}{Name?}
\newcommand{\subjectdetails}{Subject?}
\newcommand{\pagesdetails}{\pageref{endoffax}}
\renewcommand{\@oddfoot}{\begin{minipage}{\textwidth}\begin{center}\thepage~of~\pagesdetails\end{center}\end{minipage}}
\renewcommand{\@evenfoot}{\@oddfoot}

\newcommand{\totalpages}[1]{\renewcommand{\pagesdetails}{#1}}

\newcommand{\datedetails}{\today}
\newcommand{\setdate}[1]{\renewcommand{\datedetails}{#1}}

\newcommand{\cuarms}{\includegraphics{BWUni3.eps}}

\newcommand{\ComputerLaboratory}{\fontsize{14pt}{14pt}\bf Computer\hfill Laboratory}

\newcommand{\formatdofaxtop}[1]{%
	\begin{minipage}[t]{65mm}\begin{flushleft}\large
	#1
	\end{flushleft}\end{minipage}}

\newcommand{\dofaxtop}{%
\setlength{\unitlength}{1mm}
\hspace*{-30mm}\begin{picture}(170,80)(0,0)
\put(30,60){\makebox(160,20)[tl]{\parbox{\textwidth}{\fontsize{36pt}{36pt}\selectfont\it fax}}}
\put(0,0){\makebox(100,43)[tl]{\begin{tabular}{@{}r@{\hspace*{5mm}}p{65mm}@{}}
{\small To}		&\formatdofaxtop{\towhomname}\\
{\small At}		&\formatdofaxtop{\toinstdetails}\\
{\small Your Fax No.}	&\formatdofaxtop{\tofaxdetails}\\
{\small From}		&\formatdofaxtop{\fromnamedetails}\\
{\small Date}		&\formatdofaxtop{\datedetails}\\
{\small No. of pages}	&\formatdofaxtop{\pagesdetails}\\
{\small Subject}	&\formatdofaxtop{\subjectdetails}\\
\hspace*{25mm}&\\
\end{tabular}}}
\put(10,18){\makebox(160,24.5)[tr]{\cuarms}}
\put(10,18){\makebox(160,24.5)[br]{\parbox{136pt}{\ComputerLaboratory}}}
\end{picture}

\vspace*{15mm}

%\let\@oddfoot\swmfoot
\thispagestyle{empty}%
\enlargethispage{10mm}%
\begin{figure}[b!]\swmfoot\end{figure}
}


\renewcommand{\footnoterule}{}
\renewcommand{\thefootnote}{}

\newcommand{\swmfoot}{\fontsize{9pt}{10pt}\rm\hfill\begin{tabular}{@{}l@{ }l@{}}
 & \\
\multicolumn{2}{@{}l@{}}{Computer Laboratory}\\
\multicolumn{2}{@{}l@{}}{New Museums Site}\\
\multicolumn{2}{@{}l@{}}{Pembroke Street}\\
\multicolumn{2}{@{}l@{}}{Cambridge~~~CB2 3QG}\\
\multicolumn{2}{@{}l@{}}{U.K.}\\
 & \\
Tel: & \fromphonedetails\\
Fax: & \fromfaxdetails\\
E-mail: & \fromemaildetails\\
\end{tabular}%\let\@oddfoot\@empty
}


\newcommand{\dofaxbottom}{

\label{endoffax}
\cleardoublepage}


\newenvironment{fax}[4]
  {\renewcommand{\towhomname}{#1}%
   \renewcommand{\toinstdetails}{#2}%
   \renewcommand{\tofaxdetails}{#3}%
   \renewcommand{\subjectdetails}{#4}%
   \dofaxtop}
  {\dofaxbottom}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% a few options

\DeclareOption{usetimesfont}{\typeout{Replacing Sabon with Times}
  \AtEndOfClass{\usepackage{times}}}
\DeclareOption{usecmfont}{\typeout{Replacing Sabon with Computer Modern}
  \renewcommand{\ComputerLaboratory}{\fontsize{12pt}{12pt}\bf Computer\hfill Laboratory}
  \AtEndOfClass{\renewcommand{\rmdefault}{cmr}}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

\ProcessOptions\relax
