% \iffalse
% $Id: estcpmm.dtx,v 1.9 2010-03-02 22:28:29 boris Exp $
%
% Copyright 2008, 2010 Boris Veytsman
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any 
% later version.
% The latest version of the license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Boris Veytsman,
% <borisv@lk.net> 
%
% This work consists of the file estcpmm.dtx and the
% derived file estcpmm.cls
%
% \fi 
% \CheckSum{473}
%
%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~} 
%
%\iffalse
% Taken from xkeyval.dtx
%\fi
%\makeatletter
%\def\DescribeOption#1{\leavevmode\@bsphack
%              \marginpar{\raggedleft\PrintDescribeOption{#1}}%
%              \SpecialOptionIndex{#1}\@esphack\ignorespaces}
%\def\PrintDescribeOption#1{\strut\emph{option}\\\MacroFont #1\ }
%\def\SpecialOptionIndex#1{\@bsphack
%    \index{#1\actualchar{\protect\ttfamily#1}
%           (option)\encapchar usage}%
%    \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar
%           usage}\@esphack}
%\def\DescribeOptions#1{\leavevmode\@bsphack
%  \marginpar{\raggedleft\strut\emph{options}%
%  \@for\@tempa:=#1\do{%
%    \\\strut\MacroFont\@tempa\SpecialOptionIndex\@tempa
%  }}\@esphack\ignorespaces}
%\makeatother
% \newcommand{\progname}[1]{\textsf{#1}}
%
% \MakeShortVerb{|}
% \GetFileInfo{estcpmm.dtx}
% \title{\LaTeX{} Style For Munitions Management Project Reports,
% \emph{Environmental Security Technology 
% Certification Program}  
%   \thanks{\copyright 2008, Boris Veytsman}}
% \author{Boris Veytsman\thanks{%
% \href{mailto:borisv@lk.net}{\texttt{borisv@lk.net}},
% \href{mailto:boris@varphi.com}{\texttt{boris@varphi.com}}}} 
% \date{\filedate, \fileversion}
% \maketitle
% \begin{abstract}
%   This package provides class for typesetting Cost \& Performance
%   Reports and Final Reports for Munitions Management Reports,  US
%   Environmental Security Technology Certification Program.
% \end{abstract}
% \changes{v0.2}{2008/12/09}{First fully functional version} 
% \changes{v0.4}{2010/03/01}{Documentation update}
% \tableofcontents
%
% \clearpage
%\section{Introduction}
%\label{sec:intro}
%
% As described on its Web site, \url{http://www.estcp.org}, \emph{The
%   Environmental Security Technology Certification Program (ESTCP) is
%   a Department of Defense (DoD) program that promotes innovative,
%   cost-effective environmental technologies through demonstration
%   and validation at DoD sites.}  Munitions Management Projects,
% financed through this program, are required to file certain reports
% according to the approved templates. This class
% provides for typesetting Cost \& Performance reports and Final
% Reports in the \LaTeX{} framework. 
%
% The class was commissioned and paid for by US Army Corps of
% Engineers, Engineer Research and Development Center, 3909 Halls
% Ferry Road, Vicksburg, MS 39180-6199.
%
% I am grateful to Ryan E. North, RPG for his help in testing the
% package and preparing the sample files.
%
%\section{User Guide}
%\label{sec:user_guide}
%
%
%
%\subsection{Installation}
%\label{sec:ug_install}
%
% The class uses a number of \LaTeX{} packages.  Normally they should be
% present in any up-to-date distribution.  If you do not have them,
% you can download them using the links below prior to using the class.
%
% You will need \progname{PSFNSS}~\cite{Schmidt04:PSNFSS9.2}: the
% \LaTeX{} package providing the access to common PostScript fonts.
% Of course you will need the fonts themselves.  You will also need
% \progname{graphics} bundle~\cite{Carlisle05:Graphics}, packages
% \progname{geometry}~\cite{Umeki08:Geometry},
% \progname{caption}~\cite{Sommerfeldt07:Caption}  and
% \progname{fancyhdr}~\cite{Oostrum04:Fancyhdr}.
%
%
% The installation of the class follows the usual
% practice~\cite{TeXFAQ} for \LaTeX{} packages:
% \begin{enumerate}
% \item Run \progname{latex} on |estcpmm.ins|.  This will produce the
% \LaTeX{} class |estcpmm.cls|.
% \item Put the file |estcpmm.cls| to
% the place where \LaTeX{} can find it (see
% \cite{TeXFAQ} or the documentation for your \TeX{}
% system).\label{item:install} 
% \item Update the database of file names.  Again, see \cite{TeXFAQ}
% or the documentation for your \TeX{} system for the system-specific
% details.\label{item:update}
% \item The file |estcpmm.pdf| provides the documentation for the
% package (this is the file you are probably reading now).
% \end{enumerate}
% As an alternative to items~\ref{item:install} and~\ref{item:update}
% you can just put the file |estcpmm.cls| in the working directory
% where your |.tex| file is.
%
%
%\subsection{Invocation}
%\label{sec:ug_invocation}
%
% To use the class, put in the preamble of your document
% \begin{flushleft}
% |\documentclass[|\meta{options}|]{estcpmm}|
% \end{flushleft}
%
% The class recoginzes the standard \LaTeX{} options, shared by the
% most document classes~\cite{Lamport94}.
% \DescribeOptions{8pt,9pt,10pt,11pt,12pt} The default font size
% changing options (|8pt|, |9pt|, \dots, |12pt|) have no effect other
% than producing a warning in the log, since DoD requires the reports
% to use 12\,pt fonts.
%
%
%\subsection{Front Matter}
%\label{sec:ug_frontmatter}
%
% \DescribeMacro{\frontmatter}.
% The command |\frontmatter| starts the \emph{Front Matter} of the
% document.  This part includes title page, table of contents, list of
% figures, list of tables.
%
% \DescribeMacro{\logo}
% Many reports have logo in the title page.  This logo is set up by
% the command |\logo[|\meta{options}|]|\marg{file}.  The syntax of the
% command is the same as the syntax of the command |\includegraphics|
% of the \progname{graphicx} package~\cite{Carlisle05:Graphics}.  The
% obligatory argument \marg{file} is the name of the graphics file
% with the logo, and \oarg{options}, if present, may, for example, set
% the dimensions of the logo.  Note that our class uses the
% ``extended'' version \progname{graphicx} of the package with its
% ``key-value'' syntax.  For example,
% \begin{verbatim}
% \logo[width=2in]{red_corps_castle2.eps}
% \end{verbatim}
% The format of the graphics file depends on the \TeX{} engine used.
% If you use
% \progname{latex}$\to$\progname{dvips}$\to$\progname{pstopdf} route,
% then you need PostScript files (PS or EPS).  If you use
% \progname{pdflatex} engine, then you need graphics files in JPEG,
% PNG or PDF formats (see~\cite{TeXFAQ} for more information).
%
% \DescribeMacro{\title} The command |\title| is used to store project
% name.  Unlike the similar command in most document
% classes~\cite{Lamport94}, our version has both optional and
% mandatory fields: |\title[|\oarg{Short Title}|]|\marg{Full Title}.
% The full title is used in the document cover page.  The short title
% is used in footers in the document.  For example:
% \begin{verbatim}
% \title{A New Project}
% \title[A New Project]{A New Project And Great Project}
% \end{verbatim}
% 
% \DescribeMacro{\subtitle}
% The command |\subtitle|\marg{Sub Title} us used to store the project
% subtitle.  For example,
% \begin{verbatim}
% \subtitle{Final Report}
% \end{verbatim}
% 
% \DescribeMacro{\date}
% The macro |\date| stores the date of the document, for example
% \begin{verbatim}
% \date{March 2008}
% \end{verbatim}
% 
% \DescribeMacro{\projectno}
% The command |\projectno|\marg{Project Number} is used to store the
% project number.  For example,
% \begin{verbatim}
% \projectno{MM-234-t567E}
% \end{verbatim}
% 
% \DescribeMacro{\internalno}
% The command |\internalno|\marg{Internal Project Number} is used to store the
% internal project number, if applicable.  For
% example, 
% \begin{verbatim}
% \projectno{MM-234-t567E}
% \end{verbatim}
% 
%
% \DescribeMacro{\version}
% The command |\version|\marg{Version Information} is used to store
% the document version, internal project number, etc.  For example,
% \begin{verbatim}
% \version{DR-ATF-0.8}
% \end{verbatim}
% 
%
% \DescribeMacro{\author}
% The command |\author|\marg{Authors and Affiliations} stores the
% names of the authors and their affiliations.  For example:
% \begin{verbatim}
% \author{A.~U. Thor,  University of Laputa\\
%         C.~O. Rrespondent, Brobdingnag School of Technology}
% \end{verbatim}
% 
% \DescribeMacro{\maketitle}
% The command |\maketitle| typesets the title page of the report.
%
% Note that some reports require Form~298 (see, for example,
% \url{http://www.ntis.gov/pdf/rdpform.pdf}).  This form should be
% typeset separately.
%
% \DescribeMacro{\tableofcontents}
% \DescribeMacro{\listoffigures}
% \DescribeMacro{\listoftables}
% Table of contents, list of figures, list of tables are typeset with
% the usual \LaTeX{} commands~\cite{Lamport94}.  Note that these
% commands always typeset their contents starting from an odd page.
%
%
%\subsection{Main Matter}
%\label{sec:ug_mainmatter}
%
% \DescribeMacro{\mainmatter}
% The main matter starts with the macro |\mainmatter|.  The text is
% divided into sections and subsections in the usual \LaTeX{} manner.
% All familiar \LaTeX{} commands and packages should work without
% problems.
%
% Note that the class assumes that the captions of tables are put
% above the tables (this is the usual practice; the behavior of the
% standard \LaTeX{}, which expects them below the tables, is rather
% odd).
%
% \DescribeMacro{\specialsection}
% Unlike standard \LaTeX, this class includes in the table of contents
% both numbered and unnumbered sections.  If you need to have a
% section, that is not included in the table of contents, use
% |\specialsection|\marg{Title} command.
% 
%
%
%\subsection{Appendices}
%\label{sec:app}
%
%
%
% \DescribeMacro{\appendix}
% The command |\appendix| starts appendices.  Each individual appendix
% after this command should 
% be entered as either a |\section| or |\section*|.  The
% numbered sections will be called 'Appendix~A', 'Appendix~B',
% etc. (so do not use the word 'Appendix' in your titles).
%
%\StopEventually{%
% \clearpage
% \bibliography{estcpmm}
% \bibliographystyle{unsrt}}
% \clearpage
%\section{Implementation}
%\label{sec:impl}
%
%\subsection{Identification}
%\label{sec:ident}
%
% We start with the declaration who we are.  Most |.dtx| files put
% driver code in a separate driver file |.drv|.  We roll this code into the
% main file, and use the pseudo-guard |<gobble>| for it.
%    \begin{macrocode}
%<class>\NeedsTeXFormat{LaTeX2e}
%<*gobble>
\ProvidesFile{estcpmm.dtx}
%</gobble>
%<class>\ProvidesClass{estcpmm}
[2010/03/02 v0.4 Typesetting reports for ESTCP MM Reports]
%    \end{macrocode}
%
% And the driver code:
%    \begin{macrocode}
%<*gobble>
\documentclass{ltxdoc}
\usepackage{array}
\usepackage{url,amsfonts}
\usepackage[breaklinks,colorlinks,linkcolor=black,citecolor=black,
            pagecolor=black,urlcolor=black,hyperindex=false]{hyperref}
\PageIndex
\CodelineIndex
\RecordChanges
\EnableCrossrefs
\begin{document}
  \DocInput{estcpmm.dtx}
\end{document}
%</gobble> 
%<*class>
%    \end{macrocode}
%
%
%\subsection{Options}
%\label{sec:options}
%
% \begin{macro}{\estcpmm@size@warning}
% The font-changing options are not used in our setup, so we just
% produce a warning:
%    \begin{macrocode}
\long\def\estcpmm@size@warning#1{%
  \ClassWarning{estcpmm}{Size-changing option #1 will not be
    honored}}%
\DeclareOption{8pt}{\estcpmm@size@warning{\CurrentOption}}%
\DeclareOption{9pt}{\estcpmm@size@warning{\CurrentOption}}%
\DeclareOption{10pt}{\estcpmm@size@warning{\CurrentOption}}%
\DeclareOption{11pt}{\estcpmm@size@warning{\CurrentOption}}%
\DeclareOption{12pt}{\estcpmm@size@warning{\CurrentOption}}%      
%    \end{macrocode}
% \end{macro}
%
% All other options are just sent to the main class:
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ProcessOptions\relax
%    \end{macrocode}
% 
%\subsection{Loading Class and Packages}
%\label{sec:loading}
%
% We start with the base class and  packages
%    \begin{macrocode}
\LoadClass[12pt]{book}
\RequirePackage{graphicx}
\RequirePackage{caption}
\captionsetup[table]{position=top}
\captionsetup{justification=centering,font=bf}
%    \end{macrocode}
%
%\subsection{Fonts}
%\label{sec:fonts}
%
% We use Times for the main font.  The guidelines say nothing about other
% fonts, but to reproduce the familiar look, we also use Helvetica for
% the sans serifed font, and Courier for the monospaced font:
%    \begin{macrocode}
\usepackage{mathptmx}
\usepackage[scaled]{helvet}
\usepackage{courier}
%    \end{macrocode}
%
% 
% 
%\subsection{Page Dimensions and Paragraphing}
%\label{sec:page}
%
% The requirements are 1'' margin top, left, right and bottom.  Rather
% ugly from the the point of view of classical typography, but this is
% how DoD wants it.
%
%    \begin{macrocode}
\RequirePackage[margin=1in]{geometry}
%    \end{macrocode}
%
%
% \begin{macro}{\parindent}
% The paragraphs have no indentation\dots
%    \begin{macrocode}
\setlength{\parindent}{0pt}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\parskip}
%   \dots and there is one baseline skip between paragraphs
%    \begin{macrocode}
\setlength{\parskip}{\baselineskip}
%    \end{macrocode}
% \end{macro}
%
%
%\subsection{Headers and Footers}
%\label{sec:headers}
% 
% We use \progname{fancyhdr}:
%    \begin{macrocode}
\RequirePackage{fancyhdr}
%    \end{macrocode}
% 
%
% \begin{macro}{\headrulewidth}
% \begin{macro}{\footrulewidth}
%   We do not want decorative rules:
%    \begin{macrocode}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% 
%
% We do not have headers:
%    \begin{macrocode}
\pagestyle{fancy}
\lhead{}
\rhead{}
\chead{}
%    \end{macrocode}
%
%   \changes{v0.3}{2010/02/28}{Bottom-aligned footers} 
% And we put title and date in the footers:
%    \begin{macrocode}
\lfoot{\parbox[b]{\headwidth}{\setlength{\parskip}{0pt}\raggedright
    \itshape\fontsize{\@xipt}{\@xipt}\selectfont
      \@shorttitle}}
\cfoot{{\small\thepage}}
\rfoot{\textit{\small\@date}}
%    \end{macrocode}
% 
%
%
%\subsection{Front Matter}
%\label{sec:frontmatter}
%
%
% \begin{macro}{\logo}
%   The |\logo| command has the same format as |\includegraphics|.  It
%   actually sets up |\includegraphics| in |\maketitle|.
%    \begin{macrocode}
\newcommand{\logo}[2][]{\gdef\@logo{\includegraphics[#1]{#2}}}%
\def\@logo{}%
%    \end{macrocode}   
% \end{macro}
%
%
% \begin{macro}{\title}
%   We redefine the title to have both mandatory and optional
%   arguments:
%    \begin{macrocode}
\renewcommand{\title}[2][]{\gdef\@shorttitle{#1}\gdef\@title{#2}%
  \ifx\@shorttitle\@empty\gdef\@shorttitle{#2}\fi}
\def\@title{}
\def\@shorttitle{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\subtitle}
%   Subtitle:
%    \begin{macrocode}
\newcommand{\subtitle}[1]{\gdef\@subtitle{#1}}
\def\@subtitle{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\projectno}
%   Project number:
%    \begin{macrocode}
\newcommand{\projectno}[1]{\gdef\@projectno{#1}}
\def\@projectno{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\internalno}
%   Internal project number:
%    \begin{macrocode}
\newcommand{\internalno}[1]{\gdef\@internalno{#1}}
\def\@internalno{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\version}
%   Version number:
%    \begin{macrocode}
\newcommand{\version}[1]{\gdef\@version{#1}}
\def\@version{}
%    \end{macrocode}
% \end{macro}
%
%
% 
%
% \begin{macro}{\today}
%   We use only month and year in |\today|:
%    \begin{macrocode}
\def\today{\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}
%    \end{macrocode}   
% \end{macro}
%
% \begin{macro}{\maketitle}
%   The |\maketitle| macro performs all the work of typesetting the
%   informations.  Note that the guidance show flushed right title
%   page.
%    \begin{macrocode}
\def\maketitle{%
  \thispagestyle{empty}%
  \begin{flushright}%
%    \end{macrocode}
% First, we are setting up the logo---or empty space if none is
% provided:
%    \begin{macrocode}
    \raisebox{0in}[2in][1in]{\@logo}\par
%    \end{macrocode}
% And the other elements:
%    \begin{macrocode}
    \bgroup
     \fontsize{26pt}{32pt}\bfseries\selectfont\MakeUppercase{\@title}\\[-10pt]
     \rule{\textwidth}{5pt}\par
     \egroup
     \bgroup
     \fontsize{18pt}{24pt}\bfseries\selectfont
     \ifx\@subtitle\@empty\relax\else\@subtitle\par\fi
     \ifx\@projectno\@empty\relax\else Project Number \@projectno\par\fi
     \ifx\@internalno\@empty\relax\else\@internalno\par\fi
     \ifx\@date\@empty\relax\else\@date\par\fi
     \ifx\@version\@empty\relax\else\@version\par\fi
     \ifx\@author\@empty\relax\else\@author\par\fi
     \egroup
  \end{flushright}%
  \clearpage}
%    \end{macrocode}
%   
% \end{macro}
%
%
%
%
%
%\subsection{Sectioning}
%\label{sec:sectioning}
%
% \begin{macro}{\texorpdfstring}
%   \changes{v0.3}{2010/02/28}{Added macro} 
%  The package \progname{hyperref} defines this macro.  We provide it
%  to enable compatibility with it
%    \begin{macrocode}
\def\texorpdfstring{%
     \expandafter\@firstoftwo}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\phantomsection}
%   \changes{v0.3}{2010/02/28}{Added macro} 
%    Another hyperref-compatibility thing
%    \begin{macrocode}
\let\phantomsection\@empty
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@sectionprefix}
%   \changes{v0.3}{2010/02/28}{Added macro}
%   \changes{v0.4}{2010/03/01}{Moved from subsection to section}
%   This is empty, but |\appendix| redefines it to |Appendix~|.  Used
%   in formatting numbered sections.
%    \begin{macrocode}
\def\@sectionprefix{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@sectionsuffix}
%   \changes{v0.4}{2010/03/01}{Moved from subsection to section}
%   \changes{v0.3}{2010/02/28}{Added macro}
%   Another feature of section formatting.  This is empty, but
%   |\appendix| redefines it to |:|.   
%    \begin{macrocode}
\def\@sectionsuffix{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thesection}
%   \changes{v0.3}{2010/02/28}{Added decimal dot and zero after
%   section number} 
% We do not use chapter numbers in sections, and add .0 to the section
% numbers.  This is not too typographically sound, but it is
% how it is done in the Army\dots
%    \begin{macrocode}
\renewcommand \thesection {\@arabic\c@section.0}
%    \end{macrocode} 
% \end{macro}
% \begin{macro}{\thesubsection}
%   \changes{v0.3}{2010/02/28}{Added macro}
% Since we changed |\thesection|, we need to redefine this.
%    \begin{macrocode}
\renewcommand \thesubsection{\@arabic\c@section.\@arabic\c@subsection}
%    \end{macrocode} 
% \end{macro}
%
%
% \begin{macro}{\section}
%   Sections are in 14\,pt bold uppercase.  They have a decorative
%   rule after heading.  The guidelines do not say it, but it seems
%   that a section opens a new page.
%    \begin{macrocode}
\renewcommand\section{\par\cleardoublepage
  \addpenalty\@secpenalty\nobreak
  \secdef\@section\@ssection}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@section}
%   This is for numbered sections:
%    \begin{macrocode}
\def\@section[#1]#2{%
  \ifnum\c@secnumdepth>0\relax
     \refstepcounter{section}%
     \addcontentsline{toc}{section}{%
       \@sectionprefix\thesection\@sectionsuffix
       \texorpdfstring{\quad}{ }#1}%
  \else
     \addcontentsline{toc}{section}{#1}%
  \fi
  {\noindent\raggedright\interlinepenalty\@M
   \large\bfseries
   \ifnum\c@secnumdepth>0\relax
      \@sectionprefix\thesection\@sectionsuffix
      \quad\MakeUppercase{#2}%
   \else
      \MakeUppercase{#2}%
   \fi%
   \\[-10pt]\rule{\textwidth}{3pt}%
   \@afterheading
   \nobreak\par}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@ssection}
%   This is for unnumbered sections,  Note that even unnumbered
%   sections go into TOC
%    \begin{macrocode}
\def\@ssection#1{%
  \phantomsection
  \addcontentsline{toc}{section}{#1}%
  {\noindent\raggedright\interlinepenalty\@M
   \large\bfseries
      \MakeUppercase{#1}%
   \\[-10pt]\rule{\textwidth}{3pt}%
   \@afterheading
   \nobreak\par}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\subsection}
%   Subsections are also bold uppercase
%    \begin{macrocode}
\renewcommand\subsection{\par
  \addpenalty\@secpenalty\nobreak
  \secdef\@subsection\@ssubsection}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@subsection}
%   Numbered subsections:
%    \begin{macrocode}
\def\@subsection[#1]#2{%
%   \changes{v0.3}{2010/02/28}{Deleted |\MakeUppercase|}
  \ifnum\c@secnumdepth>1\relax
     \refstepcounter{subsection}%
     \addcontentsline{toc}{subsection}{%
       \thesubsection\texorpdfstring{\quad}{ }#1}%
  \else
     \addcontentsline{toc}{subsection}{#1}%
  \fi
  {\noindent\raggedright\interlinepenalty\@M
   \normalsize\bfseries
   \ifnum\c@secnumdepth>0\relax
      \thesubsection\quad#2%
   \else%
      #2%
   \fi%
   \@afterheading
   \nobreak\par}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@ssubsection}
%   \changes{v0.3}{2010/02/28}{Deleted |\MakeUppercase|}
%   Unnumbered subsections:
%    \begin{macrocode}
\def\@ssubsection#1{%
  \phantomsection
  \addcontentsline{toc}{subsection}{#1}%
  {\noindent\raggedright\interlinepenalty\@M
   \normalsize\bfseries
    #1%
   \@afterheading
   \nobreak\par}}
%    \end{macrocode}
% \end{macro}
%
%
%\subsection{Appendix}
%\label{sec:appendix}
%
% \begin{macro}{\appendix}
% \changes{v0.4}{2010/03/01}{Changed appendices to be sections rather
% than subsections}
%   \changes{v0.3}{2010/02/28}{Added macro} 
%   \changes{v0.4}{2010/03/02}{Typo corrected} 
%   Appendix changes the numbering
%   of sections and the formatting of section entries.
%    \begin{macrocode}
\renewcommand\appendix{%
  \setcounter{chapter}{0}%
  \setcounter{section}{0}%
  \renewcommand \thesection{\@Alph\c@section}%
  \renewcommand \thesubsection{\@Alph\c@section.\@arabic\c@subsection}%
  \def\@sectionprefix{Appendix~}%
  \def\@sectionsuffix{:}}
%    \end{macrocode}
%   
% \end{macro}
%
%\subsection{Special Sections}
%\label{sec:special}
%
% Since our unnumbered sections go to the toc, we need to redefine
% table of contents, list of figures, list of tables, bibliography and
% index.
%
% \begin{macro}{\specialsection}
%   A section that does not go into TOC\dots
%    \begin{macrocode}
\def\specialsection#1{%
  \par\cleardoublepage
  \addpenalty\@secpenalty\nobreak
  {\noindent\raggedright\interlinepenalty\@M
   \large\bfseries
      \MakeUppercase{#1}%
   \\[-10pt]\rule{\textwidth}{3pt}%
   \@afterheading
   \nobreak\par}}
%    \end{macrocode}   
% \end{macro}
%
% \begin{macro}{\tableofcontents}
%   TOC:
%    \begin{macrocode}
\renewcommand\tableofcontents{%
  \specialsection{\contentsname}%
  \@starttoc{toc}}
%    \end{macrocode}   
% \end{macro}
% \begin{macro}{\listoffigures}
%   LOF:
%    \begin{macrocode}
\renewcommand\listoffigures{%
  \specialsection{\listfigurename}%
  \@starttoc{lof}}
%    \end{macrocode}   
% \end{macro}
% \begin{macro}{\listoftables}
%   LOT:
%    \begin{macrocode}
\renewcommand\listoftables{%
  \specialsection{\listtablename}%
  \@starttoc{lot}}
%    \end{macrocode}   
% \end{macro}
%
% \begin{macro}{\thebibliography}
%   Bibliography uses |\section*| instead of |\chapter*|:
%    \begin{macrocode}
\renewenvironment{thebibliography}[1]
     {\section*{\bibname}%
      \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\theindex}
%   Same with the index:
%    \begin{macrocode}
\renewenvironment{theindex}
               {\section*{\indexname}%
                \parskip\z@ \@plus .3\p@\relax
                \columnseprule \z@
                \columnsep 35\p@
                \let\item\@idxitem}
               {\clearpage}
%    \end{macrocode}
%   
% \end{macro}
%
% \subsection{The final word}
%\label{sec:final}
%
%    \begin{macrocode}
%</class>      
%    \end{macrocode}
%   
%\Finale
%\clearpage
%
%\PrintChanges
%\clearpage
%\PrintIndex
%
\endinput
