% cmlab.cls
% For my CM lab sheets.
% 25 Sep 2000   Nick Urbanik <nicku@vtc.edu.hk>

% How to use this:
% 1. put this at the beginning:
%\documentclass{cmlab}

% 2. Put this next (not with a comment character, though):
% \RCS $Revision$

% 3. Finally define a lab title:
% \newcommand*{\labTitle}{Partitioning the hard disk}

% That's it!  Simple as 123.

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cmlab}[2000/09/25 For IVE CM lab sheets, with hyperref]

\DeclareOption{solutions}{%
   \AtEndOfClass%
   {%
     \setboolean{Solutions}{true}%
     \renewcommand{\s}[1]{#1}%
     \includeversion{Solutions}%
   }%
}
\DeclareOption{numPara}{%
   \AtEndOfClass%
   {%
      % I copied this from lect.cls

      \setcounter{secnumdepth}{5} % Number all headings.
      \setcounter{tocdepth}{5}          % All headings go into table of contents.

      % \newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
      %                                      {-3.25ex\@plus -1ex \@minus -.2ex}%
      %                                      {1.5ex \@plus .2ex}%
      %                                      {\reset@font\normalsize\bfseries}}
      \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                          {3.25ex \@plus1ex \@minus.2ex}%
                                          %{-1em}%
                                           {0.75ex \@plus .2ex}%
                                          {\reset@font\normalsize\bfseries}}
      \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
                                             {3.25ex \@plus1ex \@minus .2ex}%
                                             %{-1em}%
                                            {0.5ex \@plus .2ex}%
                                            {\reset@font\normalsize\bfseries}}
   }%
}

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

% Execution of options

\ProcessOptions

% Special class file commands

\LoadClass[%
  a4paper,%
  %twoside,%
  12pt]%
{article}
% Package loading

\RequirePackage{%
   nick,%
   acro,%
   booktabs,%
   varioref,%
   result3,%
   mdwlist,%
   fancyhdr,%
   geometry,%
   graphicx,%
   version,%
   cols,%
   calc,%
   url,%
   rcs%
}


\geometry{a4paper, left=25mm, right=25mm, top=8mm, bottom=10mm}


\renewcommand*{\bottomfraction}{.6} % default is 0.3
\renewcommand*{\topfraction}{.9} % default is 0.7
\renewcommand*{\textfraction}{0.05} % default is 0.2

% These two lines fix up the overwritten page number problem in the
% table of contents:  Nick, 6-12-94.
\renewcommand\@pnumwidth{3.55em}%
\renewcommand\@tocrmarg {4.55em}

\newboolean{Solutions}%
\setboolean{Solutions}{false}%
\excludeversion{Solutions}%
\newcommand{\s}[1]{}% Solution; not shown by default.
\newcommand*{\college}{Institute of Vocational Education (Tsing YI)}%
%\newcommand*{\labTitle}{Partitioning the hard disk}
\newcommand*{\subject}{Operating Systems and Systems Integration}
\newcommand*{\subjectNumber}{}%
\newcommand*{\solutionsText}{Solutions}%
\newcommand*{\department}{Department of Information \& Communications
  Technology}%
% To be able to refer to the linux_traingin materials from
% www.linuxtraining.co.uk:
\newcommand*{\linuxTrainingNotes}%
{\url{http://CSAlinux.tycm.vtc.edu.hk/ossi/linux_training-ossi/workshop-notes.pdf}}

% See fancyheadings.tex:
\def\iffloatpage#1#2{\if@fcolmade #1\else #2\fi}

\pagestyle{fancyplain}
\fancypagestyle{plain}{%
  \fancyhead{}%
  %\setlength{\headrulewidth}{0pt}%
  \renewcommand*{\headrulewidth}{0pt}%
  \fancyfoot[LE,RO]{\tiny ver. \RCSRevision}%
  \fancyfoot[LO,RE]{\tiny Nick Urbanik \url{<nicku@vtc.edu.hk>}}%
  \fancyfoot[C]{}%
}

\newcommand*{\headerfont}{\rmfamily\footnotesize\bfseries}

\fancyfoot[C]{}%
\fancyfoot[LE,RO]{\tiny ver. \RCSRevision}%
\fancyfoot[LO,RE]{\tiny Nick Urbanik \url{<nicku@vtc.edu.hk>}}%
\fancyhead[LO,RE]{\headerfont\labTitle\\\subject}
\fancyhead[LE,RO]{\headerfont\thepage}
%\fancyhead[C]{\headerfont\subject}
\fancyhead[C]%
{%
  \headerfont%
  \ifthenelse{\boolean{Solutions}}%
    {\solutionsText\\}%
  %else
    {}%
}

\newcommand*{\cmlogo}{%
  \includegraphics[width=\cmlogowidth]{cm-banner-cropped}%
  }%

% Put this straight after \begin{document}.
%\newcommand{\labHeadLogo}%
\AtBeginDocument%
{%
  % See chapterbib.sty by David Arseneau in the cite distribution for
  % ideas on finding out what has been defined.
  \@ifundefined{labTitle}{\typeout{^^J*********************^^JPlease
      set LabTitle in the preamble.^^J*********************^^J}}%
  \thispagestyle{plain}
  \newlength{\cmlogowidth}
  \setlength{\cmlogowidth}{0.3\textwidth}
  \newlength{\titlewidth}
  \setlength{\titlewidth}{\textwidth}
  %\settowidth{\cmlogowidth}{\cmlogo}
  \addtolength{\titlewidth}{-\cmlogowidth}

  \thispagestyle{plain}
  \begin{minipage}[c]{\cmlogowidth}
    \cmlogo%
  \end{minipage}
  \begin{minipage}[c]{\titlewidth}
    \centering%
    \textsc{\subject}
  \end{minipage}
  \vspace{1.5ex}
  \begin{center}
    \Large\textbf{\labTitle}
  \end{center}
}% End of labHeadLogo command.

% A utility environment, indented and smaller in size.
\newenvironment{explanation}%
{%
   \begin{list}{}%
   {%
     \setlength\parindent{1.5em}%
     \setlength{\parskip}{0.6em}%
     \rightmargin \leftmargin
     \topsep 0pt%
   }%
   \small\item[]%
}%
{\end{list}}
