% File: lab.cls
% For VTC microprocessor workshop and lab notes.
% Options: All article options and also:
% mechEng numPara
% partTime compSc
% Written by Nick Urbanik, 14-10-94

% Latest requirements by Dennis for his newer (probably not newest)
% lab sheet format:
% Put a Huge version box at the bottom of the front page.
% Leave a large empty space above this (poor trees!)
% Remove the subject name (this is sensible from the production point
% of view, but less so from the student's and lab manager's point of
% view).  Perhaps put the subject number in tiny writing under the
% revision number.
% Remove the lab sheet number (similar to above).
% There are three parts: A. Background, B. Procedure C. Discussion.
% Each part has a big font, bold header in small caps.
% Other headings are bold italic, 12pt, with a small space before the
% text.
% Headings outside of part B are not numbered.
% Headings in part B are numbered; these numbers are not bold.
% Each step of the procedure is numbered under the numbering of the
% header.
% Wherever the student needs to write or draw something, a symbol is
% shown at the margin on the left.
% Headers and footers are quite changed:
% the header has a rule, above which is the name of the College in bold
% capitals, about 10pt. 
% The footer has EE Department on the left, Page Xn, where X is A, B
% or C, and n is the pagenumber within that part, in the centre of the
% footer, and on the right is the Departmental reference number.
% These are all in bold 10pt.  I propose to add the subject code in
% tiny font under the reference number.
% Use boxes for the student to put drawings in.
% OTHER CHANGES:
% I need to change the result.sty command: the lines need to be
% indented.  Perhaps write a new style file for this.
% I need to change my numbers to being not bold.

% NOTE: the department requires a reference number for each lab sheet.
% They have been allocated by Angela as 15 codes:
%
% EE/27/LA/06/95
% EE/27/LA/07/95
% EE/27/LA/07/95
%           .
%           .
% EE/27/LA/21/95
% The first is the department; the second is the subject code; the 3rd means
% lab; the fourth is the lab number; the last is the year.

% Also, a revision box is needed at the end of each lab sheet, with the
% headings Compiled by, Issue, Date, Remark.
% Here is the one from workshop 1:
% \vfill
% 
% \begin{center}
% \tiny
% \begin{tabular}{|l|c|c|p{4cm}|}
% \hline
% \multicolumn{1}{|c|}{Compiled by} & Issue & Date &
% \multicolumn{1}{c|}{Remark} \\
% \hline
% Nick Urbanik & 1 & 4-10-95 & This is a totally new lab, written
% from scratch.  It is suitable as an introduction for all
% microprocessor courses, though it is initially targetted at a 2 hour
% workshop. \\
% \hline
% \end{tabular}
% \end{center}


% An example of the use of lab.cls:

% \documentclass{lab}
% \usepackage{lgrind,emlines2,multicol}
% Turn off lgrind's special handling of the vertical bar:
%|-

% \begin{document}
% \labHead

% \labTitle{2}{Reading an input device, using a new output device}

% \begin{objectives}
% \item To further practice the Edit/Compile/Download/Run process

% \item To understand more about how the interface board works with the
% 68230 parallel chip

% \item To understand how to read a keypad

% \item To learn a little more of the C language: specifically, about
% the bitwise operators AND (@&@), OR (@|@) and NOT (@~@), about
% comments, about arrays and about function parameters.

% \item To appreciate some tradeoffs between hardware and software in
% scanning a keypad
% \end{objectives}
% \vspace{-3.5ex}
% \begin{equipment}
% \item PC compatible computer

% \item Flight-68k 68000 microprocessor board with power supply
% and serial cable

% \item Hewlett Packard C cross compiler, assembler and linker

% \item Interface board with LEDs,
% switches and a cable to connect it to the Flight-68k board

% \item A text editor

% \item Microsoft Windows

% \item Manual for the Flight-68k board

% \item Manual for the 68230 parallel interface/timer (PI/T) chip
% \end{equipment}

% \vspace{-4ex}

% \tableofcontents

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Background information}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% End of example of the use of lab.cls.

% $Header: /usr/local/share/texmf/tex/latex/nick/RCS/lab.cls 1.13 2000/03/24 01:38:42 nicku Exp nicku $

% $Log: lab.cls $
% Revision 1.13  2000/03/24 01:38:42  nicku
% Added support for using the Solutions environment that is activated when
% select the solutions option.
%
% Revision 1.12  1999/10/19 02:37:06  nicku
% Updated to IVE, IVE logo.
% Got rid of the silly Departmental page numbering system.
%
% Revision 1.10  1998/04/20 02:19:20  Nick
% 1. Made the section headings more compact.
% 2. Updated the revision number ot 1998.
%
% Revision 1.9  1998/01/12 02:27:58  Nick
% Removed many comments.
% Minor changes.
%
% Revision 1.8  1997/09/04 04:03:53  Nick
% This version was made last year.
% I think the aim was to use the postscript logo, and to make it
% work with the labs I wrote last year.
% Now Dennis has given us yet _another_ format for the lab sheets.
% So to change it yet _again_.
%
% Revision 1.7  1996/11/11 10:06:38  Nick
% Have added support for solutions.
% Have also used the resultan.sty package instead of result.sty.
% This introduces compatibility problems that require change in the source
% before a lab can be compiled.  I hope that this is not a mistake!
%
% Revision 1.6  1996/10/23 15:32:13  Nick
% Major revisions.
% Have added embedded and other options.
% Used to print up to 23-10-96
%
% Revision 1.5  1996/10/14 03:14:59  Nick
% This is the work I did on lab.cls in the microprocessor lab.
%
% Revision 1.4  1996/10/03 19:42:46  Nick
% This is a major revision: it now works with the "correct" Departmental
% logo style.
% There is minor cheating: the subject is shown in small letters
% to avoid the massive confusion that would otherwise result.
%
% Revision 1.3  1996/10/03 01:00:46  Nick
% Huge changes since last check in at home.
%
% Revision 1.1  1996/01/03  13:06:09  Nick
% Initial revision
%
% Revision 1.9  1995/02/19 12:45:35  Nick
% Major revision.
% Changed the headers and footers.
% Added revision control support for printing version numbers in lab sheets.
%
% Revision 1.8  1994/11/05  18:50:42  Nick
% Fixed missing comments.
% Moved \eemph into nick.sty.
% Fixed the overful box warning that got each page with fancyheadings
% Added Group field on front of lab sheet.
%
% Revision 1.7  1994/10/23  21:59:43  Nick
% Added varioref to list of packages used (it's indespensible!).
% Also fixed definition of eemph.
%
% Revision 1.6  1994/10/22  17:40:27  Nick
% 1. Have added an example of use of this class.
% 2. Have added some shorthand commands.
%
% Revision 1.5  1994/10/22  16:34:17  Nick
% Have added a subject number, and the mechEng option.
%

% Identification part

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{lab}[2000/05/30 For IVE lab sheets, with hyperref]

% Latest change, 19-4-96: Have added the support for float pages to be
% without the right mark, as explained in fancyheadings.tex.  Have
% also ensured that ``References'' doesn't come out in capitals.

% Declaration of options

\DeclareOption{solutions}{%
   \AtEndOfClass%
   {%
     \setboolean{Solutions}{true}%
     \renewcommand{\s}[1]{#1}%
     \includeversion{Solutions}%
   }%
}

% For Mechanical Engineering labs, need W. K. Leung's special codes: 
\DeclareOption{mechEng}{%
   \AtEndOfClass%
   {%
      \setboolean{mechEng}{true}%
      \setboolean{elecEng}{false}%
      \includeversion{mechEng}%
      \excludeversion{comp}% 
      \excludeversion{compSc}%
      \excludeversion{embedded}%
      \excludeversion{elecEng}%
      \renewcommand*{\deptCode}{EE}%
      \renewcommand*{\subjPrefix}{219}%
      \renewcommand*{\sheetNumOffset}{5}%
      \renewcommand*{\subject}{Digital \mbox{Electronics} and
        \mbox{Microprocessors}}%
      \renewcommand*{\subjectNumber}{ME219}%
   }%
}

% For Computing (my subject), need W. K. Leung's special codes: 
\DeclareOption{comp}{%
   \AtEndOfClass%
   {%
      \setboolean{comp}{true}%
      \setboolean{elecEng}{false}%
      \excludeversion{embedded}%
      \includeversion{comp}% 
      \excludeversion{compSc}% 
      \excludeversion{mechEng}%
      \excludeversion{elecEng}%
      \renewcommand*{\deptCode}{EE}%
      \renewcommand*{\subjPrefix}{11}%
      \renewcommand*{\sheetNumOffset}{0}%
      \renewcommand*{\subject}{Introduction to \mbox{Computing}}
      \renewcommand*{\subjectNumber}{EE111}%
   }%
}

% For Computing (Michael's subject), need W. K. Leung's special codes: 
\DeclareOption{compSc}{%
   \AtEndOfClass%
   {%
      \setboolean{compSc}{true}%
      \setboolean{elecEng}{false}%
      \excludeversion{embedded}%
      \excludeversion{comp}% 
      \includeversion{compSc}% 
      \excludeversion{mechEng}%
      \excludeversion{elecEng}%
      \renewcommand*{\deptCode}{EE}%
      \renewcommand*{\subjPrefix}{13}%
      \renewcommand*{\sheetNumOffset}{13}%
      \renewcommand*{\subject}{Introduction to \mbox{Digital}
        \mbox{Technology} and \mbox{Processors}}%
      \renewcommand*{\subjectNumber}{CMFD\,111}%
   }%
}

% For Embedded Systems (Vincent's subject), need W. K. Leung's special codes: 
\DeclareOption{embedded}{%
   \AtEndOfClass%
   {%
      \setboolean{embedded}{true}%
      \setboolean{elecEng}{false}%
      \includeversion{embedded}%
      \excludeversion{comp}% 
      \excludeversion{mechEng}%
      \excludeversion{compSc}%
      \excludeversion{elecEng}%
      \renewcommand*{\deptCode}{EE}%
      \renewcommand*{\subjPrefix}{70}%
      \renewcommand*{\sheetNumOffset}{5}%
      \renewcommand*{\subject}{Embedded Systems and \mbox{Applications}}%
      \renewcommand*{\subjectNumber}{EE370}%
   }%
}

\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{%
   vmargin,%
   nick,%
   acro,%
   booktabs,%
   varioref,%
   result3,%
   mdwlist,%
   fancyhdr,%
   xspace,%
   version,%
   calc,%
   rcs%
}

% For use with pdflatex, get rid of insistence on dvips:
%\RequirePackage[dvips]{graphicx}
\RequirePackage{graphicx}
% hyperref is supposed to be last.  May not work here:
%\RequirePackage{hyperref}% NEW! 30 May 2000 for pdflatex output.

\setpapersize{A4}
%\setmarginsrb{25mm}{20mm}{25mm}{15mm}{12pt}{11mm}{0pt}{11mm}
%\setmarginsrb{25mm}{20mm}{35mm}{15mm}{12pt}{11mm}{0pt}{11mm}
%\special{papersize=210mm,297mm}% Tell DVIPS this is a4.

\setmarginsrb{25mm}% left
             {12.9mm}% top
             {25mm}% right
             {18mm}% bottom
             {8.2mm}% headheight---increase to stop fancyhead warn
             {8mm}% headsep
             {0pt}%  footheight
             {11mm}% footskip

% Nick, 5-9-96: after looking at the output from \layout, I realised
% the \marginparwidth overflows off the page.  This is probably a bug
% in the vmargin package.

\setlength{\marginparwidth}{61pt}%
\setlength{\marginparsep}{7pt}

\shiftmargins

% All changes to \textwidth to happen before here:
\pagestyle{fancyplain}

% 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}

% Nick, 9-10-95.
% Default is electrical engineering:
\newboolean{Solutions}%
\newboolean{mechEng}%
\newboolean{elecEng}%
\newboolean{comp}%
\newboolean{compSc}%
\newboolean{embedded}%
\setboolean{Solutions}{false}%
\setboolean{mechEng}{false}%
\setboolean{elecEng}{true}%
\setboolean{compSc}{false}%
\setboolean{comp}{false}%
\setboolean{embedded}{false}%
\includeversion{elecEng}%
\excludeversion{mechEng}%
\excludeversion{compSc}%
\excludeversion{comp}%
\excludeversion{embedded}%
\excludeversion{Solutions}%


\newcommand{\s}[1]{}% Solution; not shown by default.
\newcommand*{\college}{Institute of Vocational Education (Tsing YI)}%
\newcommand*{\subject}{Digital \mbox{Systems} and \mbox{Microprocessors}}%
\newcommand*{\deptCode}{EE} % Used in the Departmental code.  Seems to
                            % always be EE.
\newcommand*{\subjPrefix}{27} % Seems to always be the first two
                              % digits of the subject number.  Used in
                              % the Departmental lab sheet code.
\newcommand*{\subjectNumber}{EE270}%

% The following needs explanation.  I want to generate the numbers
% for the Department references automatically, to avoid the errors
% that will otherwise be inevitable.  The numbers generally continue
% in sequence, so the sheet number is a constant offset added to the
% lab sheet number.  The \sheetNumOffset is that constant offset that
% is later added to the lab sheet number to give the official
% Departmental code for that lab sheet.
% An example for the Departmental code for Workshop 1 for EE270.
%
%          This  is the workshop number (one) to which the offset 5
%          has been added.  Hence for EE270, the \sheetNumOffset is 5.
%           v
% EE/27/LA/06/96 
\newcommand*{\sheetNumOffset}{5}%
\newcommand*{\department}%
      {Department of Electrical and Communications Engineering}%
% These two are now in acro.sty:
% \newcommand{\up}{microprocessor\xspace}
% \newcommand{\Up}{Microprocessor\xspace}
\providecommand*{\ie}{i.e.,\xspace}
\providecommand*{\eg}{e.g.,\xspace}

% Have moved \eemph into nick.sty, since it is so useful.
% \newcommand{\eemph}[1]{\emph{\textbf{#1}}}

\newcommand{\DP}{\textsf{MS-DOS Prompt}\xspace}
\newcommand{\ed}{\textsf{MS-DOS Editor}\xspace}
\newcommand{\hp}{\textsf{HP Real-time C Debugger}\xspace}
\newcommand{\te}{\textsf{Terminal}\xspace}


% All the next section is to do the headings and footings:

\renewcommand*{\sectionmark}[1]%
          {\markboth{\thesection\ \ #1}{\thesection\ \ #1}}
\renewcommand*{\subsectionmark}[1]{\markright{\thesubsection\ \ #1}}

% See fancyheadings.tex:

%\makeatletter
\def\iffloatpage#1#2{\if@fcolmade #1\else #2\fi}
% No,, No, No!  Never put \makeatother in a style file!
%\makeatother

\fancypagestyle{plain}{%
\fancyhead{}%
\fancyfoot[LE,RO]{\tiny \revision}%
\fancyfoot[LO,RE]{\tiny Ref. \referenceNum}%
\fancyfoot[C]{}%
\renewcommand*{\headrulewidth}{0pt}%
}

\fancyfoot[C]{\headerfont Part \thepart \hspace{2em}  Page \thepage}

% Note: only difference between left and right is the ragged left and right.
%\fancyhead[RO]{%
% This is what I had previously:
%   \parbox[b]{\subjectWidth}%
%   {%
%     \headerfont\raggedleft\bfseries\subjectNumber%
%     \hspace{\subjNumNameSep}\subject%
%   }%
%}

%\fancyfoot[LE,RO]{%
% This is what I had at the end of 96/97:
%   \parbox[b]{\subjectWidth}%
%   {%
%     \headerfont\raggedright\bfseries\subjectNumber%
%     \hspace{\subjNumNameSep}\subject%
%   }%
%}

\fancyhead[LR]{}%

\fancyhead[C]%
{%
  \headerfont%
  \ifthenelse{\boolean{Solutions}}%
    {Solutions\\}%
  %else
    {}%
  \college%
}

% Note: only difference between left and right is the ragged left and right.
\fancyfoot[LO]%
{%
   \parbox[t]{\markWidth}%
   {%
      \headerfont%
      EE~Department% raggedright
      \mdseries\tiny\mbox{}\\%
      \protect\revision%
   }%
}
% On right 
\fancyfoot[RE]%
{%
   \parbox[t]{\markWidth}%
   {%
      \headerfont%
      \raggedleft%
      EE Department%
      \mdseries\tiny\mbox{}\\%
      \protect\revision%
   }%
}

\fancyfoot[LE]%
{%
   \parbox[t]{\markWidth}%
   {%
      \headerfont%
      \protect\referenceNum% raggedright
      \mdseries\tiny\mbox{}\\%
      \subjectNumber%
   }%
}%

\fancyfoot[RO]%
{%
   \parbox[t]{\markWidth}%
   {%
      \headerfont%
      \raggedleft%
      \protect\referenceNum% raggedright
      \mdseries\tiny\mbox{}\\%
      \subjectNumber%
   }%
}%
%\newcount\workshopNum%
% No, the Departmental page numbering system is too confusing:
%\renewcommand{\thepage}{\thepart-\arabic{page}}%
\renewcommand{\thepage}{\arabic{page}}%

% No use: sets page number to zero, so get zero page numbers!!
% \@addtoreset{page}{part}%

\newcount\refNumCntr%
% \newcommand{\deptCode}{}
% \newcommand*{\subjPrefix}{}
\DeclareRobustCommand{\referenceNum}%
{\deptCode/\subjPrefix/LA/\the\refNumCntr/99}

% \newcounter{refNumCntr}
% \DeclareRobustCommand{\referenceNum}{EE/27/LA/\arabic{refNumCntr}/95}

\renewcommand \thepart {\@Alph\c@part}

\renewcommand\part{\par
   \addvspace{3ex}%
   \@afterindentfalse
   \secdef\@part\@spart}

\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart:\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries \partname~\thepart:\hspace{0.5em}
%       \par\nobreak
     \fi
     \Large \bfseries #2%
     \markboth{}{}\par%
     % Nick: disable the silly Departmental page numbering standard.
     % Now pages are numbered continuously.
     %\setcounter{page}{1}%
    }%
    \nobreak
    \vskip 3ex
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \Large \bfseries #1}%
     \nobreak
     \vskip 3ex
     \@afterheading}

\renewcommand\section{\@startsection {section}{1}{\z@}%
                                    {-3.5ex \@plus -1ex \@minus -.2ex}%
                                    {2.3ex \@plus.2ex}%
                                    {\normalfont\large\slshape\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                      {-3ex\@plus -1ex \@minus -.2ex}%
                                      {1.2ex \@plus .2ex}%
                                      {\normalfont\normalsize\slshape\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                      {-2.25ex\@plus -1ex \@minus -.2ex}%
                                      {0.8ex \@plus .2ex \@minus .1ex}%
                                      {\normalfont\normalsize\slshape}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                      {3.25ex \@plus1ex \@minus.2ex}%
                                      {-1em}%
                                      {\normalfont\normalsize\bfseries}}



\newlength{\markWidth}
\setlength{\markWidth}{\textwidth}
\addtolength{\markWidth}{-4em}

% New, 4-9-97:
\newcommand*{\headerfont}{\rmfamily\small\bfseries}

\newlength{\collegeWidth}
\newlength{\colSubjNumSep}% Separate College name from
                                   % subject number
\setlength{\colSubjNumSep}{1em}

\newlength{\subjNumNameSep}% Separate subject number from
                           % subject name.
\setlength{\subjNumNameSep}{1em}

\settowidth{\collegeWidth}{\college}
\newlength{\subjectWidth}
\newlength{\subjNumWidth}
\settowidth{\subjNumWidth}{\subjectNumber}
\setlength{\subjectWidth}{\textwidth}
\addtolength{\subjectWidth}{-\colSubjNumSep}
%\addtolength{\subjectWidth}{-\subjNumNameSep}
%\addtolength{\subjectWidth}{-\subjNumWidth}
\addtolength{\subjectWidth}{-\collegeWidth}

% Get rid of these silly foot rules---no, Denis wants them back.
\renewcommand*{\footrulewidth}{0pt}

\newcommand{\labHead}{%
\thispagestyle{plain}
\begin{center}
\bfseries\large
\college

\department

\subjectNumber\hspace{1em}\subject

\end{center}

\vspace{4ex}

Name \rule{46mm}{.4pt} \hspace{6mm}
 Course, Group \rule{23mm}{.4pt} \hspace{6mm} Date \hrulefill\\
}

%\newcommand{\labHeadLogo}%
%{%
%  % See chapterbib.sty by David Arseneau in the cite distribution for
%  % ideas on finding out what has been defined.
%%  \makeatletter

%  \@ifundefined{workshopTitle}{\typeout{^^J*********************^^JPlease
%      put LabTitle in the preamble.^^J*********************^^J}}%
%%  \makeatother% Never put \makeatother in a style file!
%  \newlength{\eelogoWidth}%
%%\newcommand*{\eelogoWidth}{\tylogoaw}
%% See p. 458 of the Companion:
%%\newcommand*{\eelogo}{%
%%  {%
%%    \setlength{\fboxsep}{0pt}%
%%    \fbox{\rule{\eelogoWidth}{0pt}\rule{0pt}{\eelogoWidth}}%
%%  }%
%%}
%  \newcommand*{\eelogo}{%
%    {%
%%    \fbox{\raisebox{15mm}[0pt][\eelogoWidth]{\settylogoa}}
%%    \raisebox{15mm}[0pt][0pt]{\settylogoa}
%      \includegraphics[clip=false,height=31.5mm]{eelogo3.eps}
%      }%
%    }%
%  \settowidth{\eelogoWidth}{\eelogo}%
%%
%  \newlength{\sideWidth}%
%  \newlength{\logoSep}%
%  \setlength{\logoSep}{0em}%
%  \setlength{\sideWidth}{\textwidth}%
%  \addtolength{\sideWidth}{-\eelogoWidth}%
%  \addtolength{\sideWidth}{-\logoSep}%
%% 
%  \thispagestyle{plain}%

%  \vspace*{-13mm}

%  \noindent\eelogo\hspace{\logoSep}%
%  \begin{minipage}[b]{\sideWidth}
%    \centering%
%    {%
%      \large%
%      \noindent%
%      Vocational Training Council\\
%      {\Large Hong Kong Technical College (Tsing Yi)}
%    }\\[2ex]
%    \textbf{\small Department of Electrical \& Communications
%      Engineering}\\[1ex]
%    \noindent\textbf{\scriptsize\subjectNumber\hspace{1em}%
%      \subject}\par\vspace*{0pt}
    
%  \end{minipage}
  
%  \vspace{1.25mm}

%  \begin{center}
%    \framebox%
%    [134.5mm]%
%    {\parbox{134.5mm}{\centering\Large\textbf{Laboratory Sheet: \referenceNum%
%        \s{\mbox{}\protect\\\Huge{}SOLUTIONS}}}}
%  \end{center}

%  \vspace{1ex}

%  \noindent%
%  {\small%
%    Student name: \rule{25mm}{.4pt} \hspace{5mm}%
%    Course/Year: \rule{15mm}{.4pt} \hspace{5mm}%
%    Subject:     \rule{15mm}{.4pt} \hspace{5mm}%
%    Date: \hrulefill%
%    }

%%  \vspace{0.7mm}

%  \begin{center}
%    \noindent\large\textbf{\workshopTitle}
%  \end{center}
%}

\newcommand{\labHeadLogo}%
{%
  % See chapterbib.sty by David Arseneau in the cite distribution for
  % ideas on finding out what has been defined.
%  \makeatletter

  \@ifundefined{workshopTitle}{\typeout{^^J*********************^^JPlease
      put LabTitle in the preamble.^^J*********************^^J}}%
%  \makeatother% Never put \makeatother in a style file!
%\input{tylogoa}% Use this<<<<<<<<<<< Was: for bm2font
\newlength{\eelogoWidth}% Use this<<<<<<<<<<< for graphicx
%\newcommand*{\eelogoWidth}{\tylogoawd}% Use this<<<<<<<<<<< Was: for bm2font
% See p. 458 of the Companion:
%\newcommand*{\eelogo}{%
%  {%
%    \setlength{\fboxsep}{0pt}%
%    \fbox{\rule{\eelogoWidth}{0pt}\rule{0pt}{\eelogoWidth}}%
%  }%
%}
\setlength{\eelogoWidth}{45mm}% Use this<<<<<<<<<<< for graphicx
  \newcommand*{\eelogo}{%
    {%
%      \fbox{\raisebox{15mm}[0pt][\eelogoWidth]{\settylogoa}}
%      \parbox[b]{\eelogoWidth}{\raisebox{13mm}[0pt]{\settylogoa}}%  Was: bm2font
%      Use this^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
%      \raisebox{15mm}[0pt][0pt]{\settylogoa}
%      \includegraphics[clip=false,height=31.5mm]{eelogo3.eps}
%       \includegraphics[clip=false,height=31.5mm]{tylogo1.eps}
%       \includegraphics[clip=true,height=20mm]{ive}
       \includegraphics[clip=true,width=\eelogoWidth]{ive}
%      Use this^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ for graphicx
      }%
    }%
%   \settowidth{\eelogoWidth}{\eelogo}% Use this<<<<<<<<<<< for graphicx
%
  \newlength{\sideWidth}%
  \newlength{\logoSep}%
  \setlength{\logoSep}{0mm}%
  \setlength{\sideWidth}{\textwidth}%
  \addtolength{\sideWidth}{-\eelogoWidth}%
  \addtolength{\sideWidth}{-\logoSep}%
% 
  \thispagestyle{plain}%

  %\vspace*{-13mm}

  \noindent\eelogo\hspace{\logoSep}%
  \begin{minipage}[c]{\sideWidth}
    \centering%
    {%
      \large%
      \noindent%
      Vocational Training Council\\
      {\Large Hong Kong Institute of Vocational Education (Tsing Yi)}
    }\\[2ex]
    \textbf{\small Department of Electrical \& Communications
      Engineering}\\[4ex]
%    \noindent\textbf{\scriptsize\subjectNumber\hspace{1em}%
%      \subject}
    \par\vspace*{0pt}
    
  \end{minipage}
  
  \vspace{1.25mm}

  \begin{center}
    \framebox%
    [134.5mm]%
    {\parbox{134.5mm}{\centering\Large\textbf{Laboratory Sheet: \referenceNum%
        \s{\mbox{}\protect\\\Huge{}SOLUTIONS}}}}
  \end{center}

  \vspace{1ex}

  \noindent%
  {\small%
    Student name: \rule{25mm}{.4pt} \hspace{5mm}%
    Course/Year: \rule{15mm}{.4pt} \hspace{5mm}%
    Subject:     \rule{15mm}{.4pt} \hspace{5mm}%
    Date: \hrulefill%
    }

%  \vspace{0.7mm}

  \begin{center}
    \noindent\large\textbf{\workshopTitle}
  \end{center}
}

% \newcount\refNumCntr

\newcommand{\labTitle}[3][Workshop]%
{%
  \typeout{^^J*********************^^JlabTitle is obsolete; better to
    use LabTitle instead}%
  \typeout{Check that the reference number is correct in the
    heading.^^J*********************^^J}%
  % Yes!! It works: thanks to Wynter Snow, page 151.
   \global\def\workshopNum{#2}%
   \global\refNumCntr=#2%
   \global\advance\refNumCntr by \sheetNumOffset
   % Here is the value of the counter: \the\refNumCntr
   % This did not work; not sure why.
   % \global\setcounter{refNumCntr}{#2}
   % \addtocounter{refNumCntr}{5} % 6, 7, 8,...,21
  \begin{center}
    \noindent\large\textbf{#1 \workshopNum: #3}
  \end{center}

  \vspace{7mm}

}

\newcount\workshopCounter

\newcommand{\LabTitle}[3][Workshop]%
{%
  % Yes!! It works: thanks to Wynter Snow, page 151.
   \global\def\workshopNum{#2}%
   \global\refNumCntr=#2%
   \global\advance\refNumCntr by \sheetNumOffset
   \ifthenelse{\(\boolean{elecEng}
           \or \boolean{embedded}\)
          \and \equal{\workshopNum}{3}}%
   {%
     \global\refNumCntr = 13%
   }%
   % else
   {}%
   %
   \ifthenelse{\boolean{elecEng} \and \equal{\workshopNum}{3}}%
   {%
     \global\advance\refNumCntr by 1%
   }%
   % else
   {}%
   %
%   \ifthenelse{\boolean{embedded} \and \equal{\workshopNum}{2}}%
%   \ifthenelse{\boolean{embedded} \and \not \equal{\workshopNum}{2}}%
%   {%
%     \let\workshopCounter = \workshopNum
%     \advance\workshopCounter by -2
%     \global\def\workshopNum{\arabic{\workshopCounter}}%
%   }%
%   {%
%     \global\def\workshopNum{1}%
%   }%
%   \ifthenelse{\boolean{embedded} \and \equal{\workshopNum}{2}}%
%   {%
%   }%
%   {}%
   %
   % Here is the value of the counter: \the\refNumCntr
   % This did not work; not sure why.
   % \global\setcounter{refNumCntr}{#2}
   % \addtocounter{refNumCntr}{5} % 6, 7, 8,...,21
%    \global\def\workshopTitle{#1 \workshopNum: #3}%
    \global\def\workshopTitle{#3}%
}

\newenvironment{objectives}%
{%
   \begin{nameList}{Equipment:xx}
   \item[Objectives:]%
   \begin{thinEnumerate}
}%
{%
  \end{thinEnumerate}
   \end{nameList}%
}

\newenvironment{equipment}%
{%
   \begin{nameList}{Equipment:xx}
   \item[Equipment:]%
   \begin{thinEnumerate}
}%
{%
   \end{thinEnumerate}
   \end{nameList}%
}

\newlength{\bigDepartmentalIndent}
\setlength{\bigDepartmentalIndent}{14mm} % 5.5mm was okay with
                                          % setting itemindent.

%\newenvironment{apparatus}%
%{%
%  \noindent\textbf{Apparatus:}%
%  \begin{itemize*}%
%%  \setlength{\itemindent}{\bigDepartmentalIndent}
%  \addtolength{\leftmargin}{\bigDepartmentalIndent}
%}%
%{%
%   \end{itemize*}%
%}

%\renewenvironment{objectives}%
%{%
%  \noindent\textbf{Objectives:}%
%  \begin{itemize*}%
%%  \setlength{\itemindent}{\bigDepartmentalIndent}%
%  \addtolength{\leftmargin}{\bigDepartmentalIndent}%
%}%
%{%
%   \end{itemize*}%
%}

%\newenvironment{components}%
%{%
%  \noindent\textbf{Components:}%
%  \begin{itemize*}%
%%  \setlength{\itemindent}{\bigDepartmentalIndent}%
%  \addtolength{\leftmargin}{\bigDepartmentalIndent}%
%}%
%{%
%   \end{itemize*}%
%}

\renewenvironment{objectives}%
{%
  \medskip%
  \noindent\textbf{Objectives:}%
  \begin{list}{$\m@th\bullet$}%
    {%
      \setlength{\labelwidth}{\bigDepartmentalIndent}%
      \setlength{\leftmargin}{\labelwidth}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{0pt}%
      \setlength{\parsep}{0pt}%
      \setlength{\parskip}{0pt}%
      \setlength{\topsep}{0pt}%
      \setlength{\partopsep}{0pt}%
    }%
}%
{%
  \end{list}%
}

\newenvironment{components}%
{%
  \medskip%
  \noindent\textbf{Components:}%
  \begin{list}{$\m@th\bullet$}%
    {%
      \setlength{\labelwidth}{\bigDepartmentalIndent}%
      \setlength{\leftmargin}{\labelwidth}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{0pt}%
      \setlength{\parsep}{0pt}%
      \setlength{\parskip}{0pt}%
      \setlength{\topsep}{0pt}%
      \setlength{\partopsep}{0pt}%
    }%
}%
{%
  \end{list}%
}

\renewenvironment{equipment}%
{%
  \medskip%
  \noindent\textbf{Apparatus:}%
  \begin{list}{$\m@th\bullet$}%
    {%
      \setlength{\labelwidth}{\bigDepartmentalIndent}%
      \setlength{\leftmargin}{\labelwidth}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{0pt}%
      \setlength{\parsep}{0pt}%
      \setlength{\parskip}{0pt}%
      \setlength{\topsep}{0pt}%
      \setlength{\partopsep}{0pt}%
    }%
}%
{%
  \end{list}%
}

%\renewenvironment{equipment}%
%{%
%  \noindent\textbf{Apparatus:}
%%  \addtolength{\leftmargin}{\bigDepartmentalIndent}% Doesn't work here.
%  \begin{itemize*}%
%%  \setlength{\itemindent}{\bigDepartmentalIndent}%
%  \addtolength{\labelwidth}{\bigDepartmentalIndent}%
%}%
%{%
%   \end{itemize*}%
%}

\newenvironment{explanation}%
{%
   \begin{list}{}%
   {%
     \setlength\parindent{1.5em}%
     \setlength{\parskip}{0.6em}%
     \rightmargin \leftmargin
     \topsep 0pt%
   }%
   \small\item[]%
}%
{\end{list}}

