%-------------------------------------------------------------------
% CGUlib.sty
% useful stuff from
%                                                      Computer Graphics Unit
%                                                 Manchester Computing Centre
%                                                    University of Manchester
%
% Version 0.99c - includes boxedepsf
%
% Defined and Supported Macros
%
% \Afour     		170mm wide text
% \AfourBOUND		158mm Wide text, suitable for ring binders
% \AfourUNBOUND		Same as Afour
% \AfourWIDE		Landscape
% \daytime 		produces date and time in European format:
%			15.47, Wednesday 27th may 1987
% \today		produces today's date: Wednesday 27th may 1987
% \DayOfWeek		expands to the day of the week ("Sunday", etc.)
%
% \boxit{ text }        use to surround text / paragraphs / anything in a
%         		box. For example, typing \boxit{the} would produce
%                            +---+
%                            |the|
%                            +---+
%         		(you may want to use \strut inside the argument if the
%         		 boxit is on a line by itself).
%
% \begincomment
% \endcomment 		Text between thes is ignored; i.e.
%			text
%			\begincomment
%			This text is ignored
%			\endcomment
%			 more text
%
% 			Notes: Do NOT nest.
%			The \endcomment MUST appear at the end of a line.
%        		TeX processes each line of ignored text, so the macro
%           		is not particularly fast.  Use sparingly.  The main use
%           		is to cause TeX to pass over small blocks of text.
%
% \typeoutname{fred}
% \BibTeX
% \SliTeX
% \AmsTex
%  \commaloop{list}{command for each one}
%-------------------------------------------------------------------
% How users can set the head and foot text.
% \pagestlye{threepart}
% either \headings{}{}{} \footings{}{}{}
% or \lhead{}  \chead{} \rhead{}
%    \lfoot{}  \cfoot{} \rfoot{}
% \underon to underline the headings
% \underoff (default) to supress underling of the headings
% 
% Note
% valid arguments might be
% {\rm \protect\thepage}   to get the page number in roman font
% {\leftmark}   to get the section number 
% {\rightmark}   to get the chapter number
%
%-------------------------------------------------------------------
% Various A4 boxes
\makeatletter
\input{a4.sty}
\makeatletter
\makeatother
%
\def\Afour{% A4 page sizes for LaTeX
\oddsidemargin=0mm
\evensidemargin=-12truemm
\textwidth=170truemm
\topmargin=-45truept
\footskip=50pt
}
\def\AfourBOUND{% A4 page sizes for LaTeX
\Afour %default A4 sizes
\textwidth=158truemm
}
\def\AfourUNBOUND{% A4 page sizes for LaTeX
\Afour
\textwidth=170truemm
}
\def\AfourWIDE{% A4 (landscape) page sizes for LaTeX
\oddsidemargin=0mm
\evensidemargin=0mm
\textwidth=280truemm\textheight=190truemm
\topmargin=-45truept
}
%-------------------------------------------------------------------
%%
% \daytime 	produces date and time in European format:
%					15.47, Wednesday 27th may 1987
%
% \today	produces today's date: Wednesday 27th may 1987
%
%
%
\newcount\thm					% allocate some vars
\newcount\tht
\newcount\thh
\newcount\thten

\def\dayth{\thm = \day \tht = \thm
	    \divide \thm by 10
	    \thh= \thm		%thh is 10's
	    \multiply \thm by 10
	    \advance \tht by -\thm	% tht is unit's
	\ifnum\thh=1 th \else
	   \ifcase\tht th \or st \or nd\ \or rd \else th \fi
        \fi
	   }                
\def\today{\number\day\dayth\space \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
  ,\space \number\year}


\def\thcolon{\raise.2ex\hbox{:}}		% : centred vertically

\def\thtimeA{
   %
   % this macro writes the time in 24-hour format( hh:mm )
   %
\thm= \time				% minutes since midnight
\tht= \thm				% copy of above
\divide \thm by 60 			% mins MOD 60 => hours
\thh= \thm				% save hours
\multiply \thm by 60			% hours * 60
\advance \tht by -\thm			% get remaining minutes
\thten=10
\ifnum\thh<\thten0\fi\number\thh\thcolon% hour
\ifnum\tht<\thten0\fi\number\tht% :minute
}

\def\daytime{
    \thtimeA,\space\today
}
%------------------------------------------------------------------------------
%
%	\DayOfWeek	expands to the day of the week ("Sunday", etc.)
%
\def\DayOfWeek{%
%
% 	Calculate day of the week, return "Sunday", etc.
%
  \newcount\dow				% Gets day of the week
  \newcount\leap			% Leap year fingaler
  \newcount\x				% Temp register
  \newcount\y 				% Another temp register
%		leap = year + (month - 14)/12;
  \leap=\month \advance\leap by -14 \divide\leap by 12
  \advance\leap by \year
%		dow = (13 * (month + 10 - (month + 10)/13*12) - 1)/5
  \dow=\month \advance\dow by 10
  \y=\dow \divide\y by 13 \multiply\y by 12
  \advance\dow by -\y \multiply\dow by 13 \advance\dow by -1 \divide\dow by 5
%		dow += day + 77 + 5 * (leap % 100)/4
  \advance\dow by \day \advance\dow by 77
  \x=\leap \y=\x \divide\y by 100 \multiply\y by 100 \advance\x by -\y
  \multiply\x by 5 \divide\x by 4 \advance\dow by \x
%		dow += leap / 400
  \x=\leap \divide\x by 400 \advance\dow by \x
%		dow -= leap / 100 * 2;
%		dow = (dow % 7)
  \x=\leap \divide\x by 100 \multiply\x by 2 \advance\dow by -\x
  \x=\dow \divide\x by 7 \multiply\x by 7 \advance\dow by -\x
  \ifcase\dow Sunday\or Monday\or Tuesday\or Wednesday\or
	Thursday\or Friday\or Saturday\fi
}
%------------------------------------------------------------------------------
%
%
% BOXIT
%
% Use \boxit{ text } to surround text / paragraphs / anything in a
%         box. For example, typing \boxit{the} would produce
%                            +---+
%                            |the|
%                            +---+
%         (you may want to use \strut inside the argument if the
%         boxit is on a line by itself).
%
\def\boxit#1{\leavevmode\hbox{\vrule\vtop{\vbox{\kern.33333pt\hrule
    \kern1pt\hbox{\kern1pt\vbox{#1}\kern1pt}}\kern1pt\hrule}\vrule}}
%
%
%------------------------------------------------------------------------------
%
%
%       Comment.tex
% Macro to allow block comments in TeX
%
% Usage: Text between \begincomment and \endcomment is ignored; i.e.
%
% text
% \begincomment
%    this text is ignored
% \endcomment
% more text
%
% Notes: Do NOT nest.
%        The \endcomment MUST appear at the end of a line.
%        TeX processes each line of ignored text, so the macro
%           is not particularly fast.  Use sparingly.  The main use
%           is to cause TeX to pass over small blocks of text.
%
% J.C. Alexander,  May, 1986
%
\edef\Saveatcatcode{\the\catcode`\@}
\catcode`\@=11
\def\newcodes@{\edef\S@veslashcatcode{\the\catcode`\\}
               \edef\S@velbraccatcode{\the\catcode`\{}
               \edef\S@verbraccatcode{\the\catcode`\}}
               \edef\S@venumsgcatcode{\the\catcode`\#}
               \edef\S@veperctcatcode{\the\catcode`\%}
 \catcode`\\=12 \catcode`\{=12 \catcode`\}=12 \catcode`\#=12
 \catcode`\%=12\relax}
\def\oldcodes@{\catcode`\\=\S@veslashcatcode
               \catcode`\{=\S@velbraccatcode
               \catcode`\}=\S@verbraccatcode
               \catcode`\#=\S@venumsgcatcode
               \catcode`\%=\S@veperctcatcode
               \relax}
\def\begincomment{\newcodes@\endlinechar=10 \comment@}
{\lccode`\!=`\\
\lowercase{\gdef\comment@#1^^J{\comment@@#1!endcomment\comment@@@}%
\gdef\comment@@#1!endcomment{\futurelet\next\comment@@@}%
\gdef\comment@@@#1\comment@@@{\ifx\next\comment@@@\let
\next=\comment@\else\def\next{\oldcodes@\endlinechar=`\^^M\relax}%
 \fi\next}}}
\catcode`\@=\Saveatcatcode
%
%------------------------------------------------------------------------------
%
% Here is a macro used to display a paremthesized matrix in a tabular
% environment.
%
\newcommand{\tabularmatrix}[1]{\begin{center}\begin{math}
                         \left(\begin{array}{cccc}#1\end{array}\right)
                        \end{math}\end{center}}
%
%------------------------------------------------------------------------------
\newcommand{\typeoutname}[1]{{\def\\{,}\let\_=_\let\$=$\escapechar=-1\message{#1,}}}
%------------------------------------------------------------------------------
%
\newcommand{\BibTeX}{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
%
\newcommand{\SliTeX}{{\rm S\kern-.06em{\sc l\kern-.035emi}\kern-.06em T\kern
   -.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\newcommand{\SLiTeX}{\SliTeX}
%
\newcommand{\AmsTeX}{{$\cal A$}\kern-.1667em\lower.5ex\hbox
{$\cal M$}\kern-.125em{$\cal S$}-\TeX}
%------------------------------------------------------------------------------
%CGU specials
%
% \bline{n}	outputs n blank lines
\newcommand{\bline}[1]{\vspace{#1 em}}
%-------------------------------------------------------------------
%Toby's KRT3 logo
\newcommand{\krtlogo}
{\special{psfile=tex$inputs:krt3logo.ps voffset=-100}}
%-------------------------------------------------------------------
% two dots
\def\twodots{\thinspace.\thinspace.\thinspace}
%-------------------------------------------------------------------------------
% Logos
%
\def\KRT3{{\sl KRT\raise .6ex\hbox{3}}}
\def\krt3{{\sl KRT\raise .6ex\hbox{3}}}
% Define PHIGS+ macro
\def\PHIGSPLUS{{\sl P\kern-.1emHIGS\kern.1em\raise1.2ex\hbox{\protect\tiny +}}}
\def\phigsplus{{\sl P\kern-.1emHIGS\kern.1em\raise1.2ex\hbox{\protect\tiny +}}}
% Define PHIGS macro
\def\phigs{{\sl P\kern-.1emHIGS}}
\def\PHIGS{{\sl P\kern-.1emHIGS}}
% Define GKS-3D macro
\def\gksthreed{\mbox{GKS--3D}}
\def\GKSTHREED{\mbox{GKS--3D}}
%------------------------------------------------------------------------------
% Starts a paragraph with a big letter.
% It only works with 10pt at the moment, because the largest size we
% can have is 25pt.
% The amount by which to \lower the character may need adjusting, 
% but 1.2em seems ok. Call the macro as \Start{1.2em}{L}.
\def\Start#1#2{\noindent\hangindent3em\hangafter-2
\smash{\lower#1\hbox to 0pt{\hskip-\hangindent\Huge #2\hfill}}}
%------------------------------------------------------------------------------
\makeatletter
\input{threepart.sty}
% Default page style
% Reset to default. Hangover from threepart explicitly in documentstyl[]
\ps@plain
%------------------------------------------------------------------------------
\newcommand{\commaloop}[2]{
\@for \@wth:=#1\do {#2{\@wth}}
}

%------------------------------------------------------------------------------
% Set up Defaults
% Technical documents don't look very good with indented paragraphs,
% so set parindent to zero, and increse parskip.  To do this job properly,
% the space above and below all of the list making enviroments should be
% reduced by this ammount as well - again I may do this someday.

\AfourBOUND
\setlength{\parindent}{0pt}
\setlength{\parskip}{7pt plus 2pt minus 1pt}

%-------------------------------------------------------------------
