Major reorganization. Vast improvements.
[drexel-thesis.git] / drexel-thesis.dtx
index c757ab1fcd36527c65af710cec2118fd1616e23e..b5b91b8a27cbcef91e890979bb0b7e6b0881d738 100644 (file)
     backgroundcolor=\color{yellow!20},xleftmargin=\fboxsep,%
     xrightmargin=\fboxsep,gobble=1}}{}
 %</driver>
-% \TeX's arguments aren't optional/mandatory, but they do use brackets
-% and braces.
-%<*driver>
-\newcommand{\bracearg}[1]{\marg{#1}}
-\newcommand{\brackarg}[1]{\oarg{#1}}
-%</driver>
 % Define a quick and dirty version of |xkeyval|'s |\DescribeOptions|.
 %<*driver>
 \newenvironment{option}[1]{\begin{macro}{#1}}
                           {\end{macro}}
 %</driver>
+% Some commonly used abbreviations from |classes.dtx|.
+%<*driver>
+\newcommand*{\Lopt}[1]{\textsf {#1}}
+\newcommand*{\file}[1]{\texttt {#1}}
+\newcommand*{\Lcount}[1]{\textsl {\small#1}}
+\newcommand*{\pstyle}[1]{\textsl {#1}}
+%</driver>
 %<*driver>
 \makeatletter
 \def\DescribeOption#1{\leavevmode\@bsphack
 % \changes{0.1}{2006/01/18}{Rewrite by Daniel J.~Cross}
 % \changes{0.2}{2010/01/09}{W.~Trevor King transitioned from thesis.cls
 %   to drexel-thesis.dtx and did a good deal of reorganizing.}
-% \changes{0.2}{2010/01/09}{W.~Trevor King merged drexelthesis.cls
+% \changes{0.3}{2010/01/11}{W.~Trevor King merged drexelthesis.cls
 %   developed in the Comp.~Sci.~Department by Jeff Abrahamson,
 %   Evan Sultanik, C.Y.~Ip, Christopher S.~Dahn, Christopher D.~Cera,
 %   Mitchell Peabody, David T.~McWherter, and Vincent A.~Cicirello.
-%   Based on the University of Toronto Thesis LaTeX2e Class.}
+%   Based on the University of Toronto Thesis \LaTeXe\ Class.  Also
+%   greatly improved the documentation by incorperating bits of
+%   the base/*.dtx files.}
 %
 % \MakeShortVerb{\|}
 % \newcommand{\pkg}[1]{\textsf{#1}}
 %
 % \maketitle
 %
+%
 % \section{Introduction}
 %
 % This package defines a \LaTeX\ thesis class for Drexel University
 % \subsection{Options}
 %
 % \DescribeOptions{final,draft}
-% The default option (selected if not options are passed) is |final|
-% mode, which has all the proper formatting and spacing for your final
-% product. The other main option is |draft| mode, which reduces all
-% the spacing in the document, so might be helpful when printing out
-% drafts (saves paper).
-%
-% |final| mode corresponds to (with Thesis Manual chapter and verse)\\
+% The default option (selected if not options are passed) is
+% \Lopt{final} mode, which has all the proper formatting and spacing
+% for your final product. The other main option is \Lopt{draft} mode,
+% which reduces all the spacing in the document, so might be helpful
+% when printing out drafts (saves paper).
+%
+% \Lopt{final} mode corresponds to (with Thesis Manual chapter and
+% verse) \\
 % \begin{tabular}{r p{0.8\textwidth}}
-%   |oneside| & 1.5 Library Submission Information, Print
+%   \Lopt{oneside} & 1.5 Library Submission Information, Print
 %     Version: ``All copies must be: \ldots Typed/printed on only one
 %     side of the page (not double-sided).'' \\
-%   |finalspace| & Assorted single, double, and triple spacing
+%   \Lopt{finalspace} & Assorted single, double, and triple spacing
 %   directives. \\
-%   |dottedtoc| & From the example on p17.
+%   \Lopt{dottedtoc} & From the example on p17.
 % \end{tabular}
 %
-% |draft| mode corresponds to \\
+% \Lopt{draft} mode corresponds to \\
 % \begin{tabular}{r p{0.8\textwidth}}
-%   |twoside| & Save space. \\
-%   |draftspace| & Save space. \\
-%   |dottedtoc| & Might as well be consistent with |final|. \\
-%   |draftwatermark| & It's good to have a timestamp. \\
+%   \Lopt{twoside} & Save space. \\
+%   \Lopt{draftspace} & Save space. \\
+%   \Lopt{dottedtoc} & Might as well be consistent with \Lopt{final}. \\
+%   \Lopt{draftwatermark} & It's good to have a timestamp. \\
 % \end{tabular}
 %
 % \DescribeOption{finalspace}
 %                  dottedpart,boldpart,
 %                  dottedchapter,boldchapter}
 % These options change how the relevant TOC lines are printed
-% \LaTeX\ defaults to bold but not dots.  The |*toc| options set all
-% of the types.  For example, |boldtoc| is equivalent to
-% |boldchapter,boldpart|.
+% \LaTeX\ defaults to bold but not dots.  The \Lopt{*toc} options set
+% all of the types.  For example, \Lopt{boldtoc} is equivalent to
+% \Lopt{boldchapter,boldpart}.
 %
 % \DescribeOption{draftwatermark}
-% |draftwatermark| adds ``DRAFT \meta{date}'' watermarks to each page.
-% A useful way to remember that the version you're looking at is not final.
-% Also helps reviewers tell you what version they're correcting.
+% \Lopt{draftwatermark} adds ``DRAFT \meta{date}'' watermarks to each
+% page.  A useful way to remember that the version you're looking at
+% is not final.  Also helps reviewers tell you what version they're
+% correcting.
 %
 %
 % \subsubsection{Interesting \cls{book} options}
 % Setup output for two-sided printing.
 %
 % \DescribeOption{leqno}
-% |leqno| places the numbering of formulae on the left hand side
+% \Lopt{leqno} places the numbering of formulae on the left hand side
 % instead of the right.
 %
 % \DescribeOption{fleqn}
-% |fleqn| typesets displayed formulae left-aligned instead of
+% \Lopt{fleqn} typesets displayed formulae left-aligned instead of
 % centered.
 %
 %
 % \end{example}
 %
 % \begin{command}
-%   `\cs{makecopyright}'
-%   `\cs{makecopyrightCC}'
+%   `\cs{copyrighttext}\marg{text}'
+% \end{command}
+% \DescribeMacro{\copyrighttext}
+% Use this macro to set the copyright text to \meta{text}.
+% The default value is ``All Rights Reserved.''.
+% \begin{example}
+%   \copyrighttext{Released to the Public Domain.}
+% \end{example}
+% See the Manual 3.2 p9.
+%
+% \begin{command}
+%   `\cs{copyrighttextCC}'
 % \end{command}
-% \DescribeMacro{\makecopyright}
-% \DescribeMacro{\makecopyrightCC}
-% Write the copyright page (Manual 3.2 p9).
-% Use |\makecopyright| to reserve all rights or |\makecopyrightCC| for
-% a Creative Commons copyright.
+% There are a number of predefined copyright messages for ease of use \\
+% \begin{tabular}{l l}
+%   |\copyrighttextCC| & Creative Commons copyright \\
+% \end{tabular}
 %
 % \begin{command}
 %   `\cs{tableofcontents}'
 %      \caption{Some caption text}
 %   \end{float}
 % \end{example}
-% Note that you'll want to use the
+% \pkg{drexel-thesis} loads
 % \href{http://www.ctan.org/tex-archive/macros/latex/required/graphics/}{\pkg{graphicx}}
-% package to define the |\includegraphics| macro.  For more useful
+% to define the |\includegraphics| macro.  For more useful
 % float information, see the
-% \href{http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}{\LaTeX wikibook page}.
+% \href{http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}
+%   {\LaTeX\ wikibook page}.
 % 
 %
 % \subsubsection{Citations}
 %
 % I highly recommend using \BibTeX\ and
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/}{\pkg{natbib}}.
-% See Section \ref{sec:natbib-example} for a simple example.
+% See Section \ref{sec:better-example} for a simple example.
 %
 % Suggested options:\\
 % \begin{tabular}{r p{0.8\textwidth}}
 %
 %
 % \section{Implementation}
-% \iffalse meta-comment
+%    \begin{macrocode}
 %<*class>
-% \fi
+%    \end{macrocode}
 %
 % For simplicity, we'll derive everything from the standard \cls{book}
 % class.
 \newif\if@final \@finalfalse
 %    \end{macrocode}
 %
-% Define some strings to store option arguments
-%    \begin{macrocode}
-\newcommand{\@advisor}{ }
-\newcommand{\def@month}{ }
-\newcommand{\def@year}{ }
-\newcommand{\@degree}{ }
-%    \end{macrocode}
 % \begin{option}{finalspace}
 %    \begin{macrocode}
 \DeclareOptionX{finalspace}{
   \setlength\overfullrule{0pt}
-  \def\@csp{2} % content page spacing
-  \def\@dsp{1} % display (math) spacing
+  \def\@cont@sep{1} % content page separation (# blanklines between entries)
   \def\@ssp{1} % single space
   \def\@dsp{2} % double space
   \def\@tsp{3} % triple space
 %    \begin{macrocode}
 \DeclareOptionX{draftspace}{
   \setlength\overfullrule{5pt}
-  \def\@csp{1} % content page spacing
-  \def\@dsp{0.2} % display (math) spacing
+  \def\@cont@sep{0} % content page separation (# blanklines between entries)
   \def\@ssp{1} % single space
   \def\@dsp{1} % double space
   \def\@tsp{2} % triple space
+%    \end{macrocode}
+%  Don't force chapters onto right-hand pages.
+%    \begin{macrocode}
+  \PassOptionsToClass{openany}{book}
   \@finalfalse
 }
 %    \end{macrocode}
 %    \end{macrocode}
 % \end{option}
 %
-% Define the book options that |final| and |draft| need to access.
+% Define the book options that \Lopt{final} and \Lopt{draft} need to
+% access.
 % \begin{option}{oneside}
 %    \begin{macrocode}
 \DeclareOptionX{oneside}{\PassOptionsToClass{oneside}{book}}
 % \end{option}
 %
 % Use the default \cls{book} implementation for any remaining options
-% including |oneside|, |twoside|, |leqno|, |fleqn|,
+% including \Lopt{oneside}, \Lopt{twoside}, \Lopt{leqno}, \Lopt{fleqn},
 % \ldots.
 %    \begin{macrocode}
 \DeclareOptionX*{\PassOptionsToClass{\CurrentOption}{book}}
 %
 % \subsection{Internal package includes}
 %
+
 % Include some other packages we'll need.  If the package is not
 % installed on your system, see Section \ref{sec:dependencies} for
 % installation instructions.
 %
+% For many packages, we want the same functionality for both
+% \Lopt{final} and \Lopt{draft} modes.  We pass \Lopt{final} to most
+% of those packages to override a possible \Lopt{draft} option passed
+% to \pkg{drexel-thesis}.
+%
+%
+% \subsubsection{\pkg{setspace}}
+%
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/setspace/}{\pkg{setspace}}
 % for double spacing.
 %    \begin{macrocode}
 \RequirePackage{setspace}
 %    \end{macrocode}
 %
+% \subsubsection{\pkg{calc}}
+%
 % \href{http://www.ctan.org/tex-archive/macros/latex/required/tools/}{\pkg{calc}}
 % for |\blanklines| macro.
 %    \begin{macrocode}
 \RequirePackage{calc}
 %    \end{macrocode}
 %
+% \subsubsection{\pkg{graphicx}}
+%
+% \href{http://www.ctan.org/tex-archive/macros/latex/required/graphics/}{\pkg{graphicx}}
+% for |\includegraphics|.  Not strictly necessary, but I can't imagine
+% a thesis without figures.
+%    \begin{macrocode}
+\RequirePackage[final]{graphicx}
+%    \end{macrocode}
+%
+% We include the graphicx package now so we can
+% pass \Lopt{final}, because some later packages include it with no options,
+% and a \Lopt{final} include after that produces errors like
+% \begin{example}
+%   l.104 \RequirePackage
+%                        [final]{ifpdf}
+%   The package graphicx has already been loaded with options:
+%     []
+%   There has now been an attempt to load it with options
+%     [final]
+% \end{example}
+%
+% \subsubsection{\pkg{draftmark}}
+%
 % The Comp.~Sci.\ class used
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/draftcopy/}{\pkg{draftcopy}}
 % to add their watermarks, but as of the current 2002/02/25 v2.16, it
 %  \href{http://www.ctan.org/tex-archive/macros/latex/contrib/lastpage/}{\pkg{lastpage}},
 %  if only I had the space to install |texlive-latexextra| |:p|).
 % The output is, however, very flexible, and it \emph{does} work with
-% both \LaTeX and pdf\LaTeX.  If you don't like the default watermark,
+% both \LaTeX\ and pdf\LaTeX.  If you don't like the default watermark,
 % you can also adjust the particulars with |\draftmarksetup|.
 %    \begin{macrocode}
 \if@draftwatermark
 \fi
 %    \end{macrocode}
 %
+% \subsubsection{\pkg{geometry}}
+%
 % Setup page margins with the
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/geometry/}{\pkg{geometry}}
 % package.  From the Manual p5:
 %   \item All other margins (top, bottom, and right) must be at least 1''.
 % \end{itemize}
 % And from the Manual 1.5 p4, Print Version:
-% ``The paper size must be 8 1/2'' x 11''{}''.
+% \begin{quote}
+%   The paper size must be 8 1/2'' x 11''.
+% \end{quote}
 %    \begin{macrocode}
 \RequirePackage[letterpaper,margin=1in,bindingoffset=0.5in]{geometry}
 %    \end{macrocode}
 % Note that we include the \pkg{geometry} package after loading \cls{book} to
 % override the margin manipulation that takes place in \cls{book}.
 %
+% \subsubsection{\pkg{fancyhdr}}
+%
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/}{\pkg{fancyhdr}}
 % for correct page numbering and fancy headers.
 %    \begin{macrocode}
 }
 %    \end{macrocode}
 %
-% Setup colon rather than period separated chapter marks, overriding
-% \cls{book}'s |\chaptermark|.
-%    \begin{macrocode}
-\renewcommand\chaptermark[1]{%
-  \markboth {\MakeUppercase{%
-    \ifnum \c@secnumdepth >\m@ne
-      \if@mainmatter
-        \@chapapp\ \thechapter: \ %
-      \fi
-    \fi
-    #1}}{}}
-%    \begin{macrocode}
-%
-% Setup space rather than period separated section marks, overriding
-% \cls{book}'s |\sectionmark|.
-%    \begin{macrocode}
-\renewcommand{\sectionmark}[1]{%
-  \markright {\MakeUppercase{%
-    \ifnum \c@secnumdepth >\z@
-      \thesection \ %
-    \fi
-    #1}}}
-%    \end{macrocode}
 %
-% \href{http://www.ctan.org/tex-archive/macros/latex/required/graphics/}{\pkg{graphicx}}
-% for |\includegraphics|.  Not strictly necessary, but I can't imagine
-% a thesis without figures.
-%    \begin{macrocode}
-\RequirePackage{graphicx}
-%    \end{macrocode}
+% \subsubsection{\pkg{ifpdf}}
 %
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/}{\pkg{ifpdf}}
 % for detecting PDF drivers.  We use it to configure \pkg{hyperref} below.
 \RequirePackage{ifpdf}
 %    \end{macrocode}
 % 
+% \subsubsection{\pkg{hyperref}}
+%
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/hyperref/}{\pkg{hyperref}}
 % for hyperlinks.  Not strictly necessary, but I can't imagine a
 % thesis without it.
 %    \begin{macrocode}
-\RequirePackage{hyperref}
+\RequirePackage[final]{hyperref}
 %    \end{macrocode}
 % Nobody likes the default colored boxes.  Color the text itself.
 %    \begin{macrocode}
 % |\author|, etc.\ to avoid using |\AtBeginDocument| or some such.
 %
 %
-% \subsection{Macros}
+% \subsection{\LaTeX\ overrides and extensions}
+%
+% Here we change the behavior of a bunch of macros and environments
+% from \file{latex.ltx} (generated by \file{format.ins} in
+% \href{http://www.ctan.org/tex-archive/macros/latex/base/}{\pkg{base}}).
+% We'll copy in their original notes along with their code, following
+% the relevant documentation an order given in \file{format.ins} and
+% the associated \file{*.dtx} files.
+%
+%
+% \subsubsection{\file{ltsect.dtx}}
 %
-% \begin{macro}{\author}
-% Override |latex.ltx|'s |\author| to set \pkg{hyperref}'s |pdfauthor|.
-%    \begin{macrocode}
-\renewcommand{\author}[1]{
-  \gdef\@author{#1}
-  \ifpdf \hypersetup{pdfauthor={\@author}} \fi
-}
-%    \end{macrocode}
-% \end{macro}
 % \begin{macro}{\title}
-% Override |latex.ltx|'s |\title| to set \pkg{hyperref}'s |pdftitle|.
+% |\title| for use in |\maketitle|. If not given |\maketitle| will
+% produce a warning message (\file{ltsect.dtx}, L117).
+%
+% We extend |\title| to set \pkg{hyperref}'s |pdftitle|.
+% (\file{ltsect.dtx}, L117).
 %    \begin{macrocode}
+\let\DUT@title\title
 \renewcommand{\title}[1]{
-  \gdef\@title{#1}
+  \DUT@title{#1}
   \ifpdf \hypersetup{pdftitle={\@title}} \fi
 }
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\advisor}
+%
+% \begin{macro}{\author}
+% |\author| for use in |\maketitle|.  If not given |\maketitle| will
+% produce a warning message (\file{ltsect.dtx}, L129).
+%
+% We extend |\author| to set \pkg{hyperref}'s |pdfauthor|.
+% (\file{ltsect.dtx}, L129).
 %    \begin{macrocode}
-\newcommand{\advisor}[1]{\renewcommand{\@advisor}{#1}}
+\let\DUT@author\author
+\renewcommand{\author}[1]{
+  \DUT@author{#1}
+  \ifpdf \hypersetup{pdfauthor={\@author}} \fi
+}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\defmonth}
+%
+% In a similar vein, we some additional meta-info macros.
+%
+%  \begin{macro}{\advisor}
+%  \begin{macro}{\@advisor}
+% |\advisor| for use in |\maketitle|.  If not given |\maketitle| will
+% produce an error message.
 %    \begin{macrocode}
-\newcommand{\defmonth}[1]{\renewcommand{\def@month}{#1}}
+\def\advisor#1{\gdef\@advisor{#1}}
+\def\@advisor{\@latex@error{No \noexpand\advisor given}\@ehc}
 %    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\defyear}
+%  \end{macro}
+%  \end{macro}
+%
+%  \begin{macro}{\defmonth}
+%  \begin{macro}{\@defmonth}
+% |\defmonth| (defense month) for use in |\maketitle|.  If not given
+% |\maketitle| will produce an error message.
 %    \begin{macrocode}
-\newcommand{\defyear}[1]{\renewcommand{\def@year}{#1}}
+\def\defmonth#1{\gdef\def@month{#1}}
+\def\def@month{\@latex@error{No \noexpand\defmonth given}\@ehc}
 %    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\degree}
+%  \end{macro}
+%  \end{macro}
+%
+%  \begin{macro}{\defyear}
+%  \begin{macro}{\@defyear}
+% |\defyear| (defense year) for use in |\maketitle|.  If not given
+% |\maketitle| will produce an error message.
 %    \begin{macrocode}
-\newcommand{\degree}[1]{
-  \renewcommand{\@degree}{#1}
-  \ifpdf \hypersetup{pdfsubject={\@degree}} \fi
-}
-%    \hypersetup{pdfauthor={\@author}}
-%    \hypersetup{pdftitle={\@title}}
-%    \hypersetup{pdfstartview=FitH}
-%  }
+\def\defyear#1{\gdef\def@year{#1}}
+\def\def@year{\@latex@error{No \noexpand\defyear given}\@ehc}
 %    \end{macrocode}
-% \end{macro}
+%  \end{macro}
+%  \end{macro}
 %
-% Set the official names of the various sections encountered
-% \begin{macro}{\dedicationsname}
-% From the Manual 3.3 p9, ``The heading |Dedications| must appear at
-% the top of the page.''
+%  \begin{macro}{\degree}
+%  \begin{macro}{\@degree}
+% |\degree| for use in |\maketitle|.  If not given |\maketitle| will
+% produce an error message.
 %    \begin{macrocode}
-\newcommand\dedicationsname{Dedications}
+\def\degree#1{\gdef\@degree{#1}
+  \ifpdf \hypersetup{pdfsubject={\@degree}} \fi}
+\def\@advisor{\@latex@error{No \noexpand\degree given}\@ehc}
 %    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\acknowledgmentsname}
-% From the Manual 3.4 p9, ``The heading |Acknowledgments| must appear
-% at the top of the page.''
+%  \end{macro}
+%  \end{macro}
+%
+%  \begin{macro}{\copyrighttext}
+%  \begin{macro}{\@copyrighttext}
+% |\copyrighttext| for use in |\makecopyright|.  There are a number of
+% blurbs predefined in Section \ref{sec:implement-copyright}.
 %    \begin{macrocode}
-\newcommand\acknowledgmentsname{Acknowledgments}
+\def\copyrighttext#1{\gdef\@copyrighttext{#1}}
+\def\@copyrighttext{All Rights Reserved.}
+%    \end{macrocode}
+%  \end{macro}
+%  \end{macro}
+%
+%
+% \begin{command}
+%   `\cs{AddContentsLine}\marg{table}\marg{type}\marg{notcap}\marg{entry}'
+% \end{command}
+% \begin{macro}{\AddContentsLine}
+% Define a version of |\addcontentsline| that capitalizes \meta{entry}.
+% \meta{notcap} allows for |\numberline| bits, etc.
+%    \begin{macrocode}
+\newcommand{\AddContentsLine}{\@ifstar
+  \@AddContentsLine\@sAddContentsLine}
+\newcommand{\@AddContentsLine}[4]{%
+%  \addcontentsline{#1}{#2}{#3#4}}
+  \addcontentsline{#1}{#2}{#3\uppercase{#4}}}
+\newcommand{\@sAddContentsLine}[4]{%
+%  \addcontentsline{#1}{#2}{#3#4}}
+  \addcontentsline{#1}{#2}{#3\uppercase{#4}}}
+%  \addcontentsline{#1}{#2}{#3\MakeUppercase{#4}}}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\contentsname}
-% From the Manual 3.5 p9, ``The heading |Table of Contents| must
-% appear at the top of the page.''  Override \cls{book}'s definition.
+%
+%
+% \begin{macro}{\@dottedtocline}
+% |\@dottedtocline{|\meta{level}|}{|\meta{indent}|}{|\meta{numwidth}%
+%        |}{|\meta{title}|}{|\meta{page}|}|:
+%   Macro to produce a table of contents line with the following
+%   parameters:
+%   \begin{description}
+%   \item[level] If \meta{level} $>$ |\c@tocdepth|, then no line 
+%                produced.
+%   \item[indent] Total indentation from the left margin.
+%   \item[numwidth] Width of box for number if the \meta{title} has a
+%                |\numberline| command.  This is also the amount of extra
+%                indentation added to second and later lines of a
+%                multiple line entry.
+%   \item[title] Contents of entry.
+%   \item[page] Page number.
+%  \end{description}
+%
+%  Uses the following parameters, which must be set by the document
+%  style. They should be defined with |\def|'s.
+%  \begin{description}
+%  \item[|\@pnumwidth|]  Width of box in which page number is set.
+%  \item[|\@tocrmarg|] Right margin indentation for all but last line
+%        of multiple-line entries.
+%  \item[|\@dotsep|] Separation between dots, in mu units.
+%                  Should be |\def|'d to a number like 2 or 1.7
+%  \end{description}
+%
+% We just add |spacing| environments to \cls{book}'s version.
+% (\file{ltsect.dtx}, L804).
 %    \begin{macrocode}
-\renewcommand\contentsname{Table of Contents}
+\def\@dottedtocline#1#2#3#4#5{%
+  \begin{spacing}{\@ssp}
+  \ifnum #1>\c@tocdepth \else
+    \vskip \z@ \@plus.2\p@
+    {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
+     \parindent #2\relax\@afterindenttrue
+     \interlinepenalty\@M
+     \leavevmode
+     \@tempdima #3\relax
+     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
+     {#4}\nobreak
+     \leaders\hbox{$\m@th
+        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
+        mu$}\hfill
+     \nobreak
+     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
+     \par}%
+     \blanklines{\@cont@sep}
+  \fi
+  \end{spacing}
+}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\listtablename}
-% From the Manual 3.6 p10, ``The heading |List of Tables| must appear
-% at the top of the page.''
-% Override \cls{book}'s definition.
+%
+%
+% Fix |\@ssect| and |\@sect| from \file{latex.ltx} to give single
+% spaced headings.
+%
+% \begin{macro}{\@sect}
+% Pseudocode for the |\@sect| command
+%     \begin{macrocode}
+% \@sect{NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}[ARG1]{ARG2}
+%           ==
+%   BEGIN
+%    IF LEVEL > \c@secnumdepth
+%      THEN \@svsec :=L null
+%      ELSE \refstepcounter{NAME}
+%           \@svsec :=L BEGIN \@seccntformat{#1}\relax END
+%    FI
+%    IF AFTERSKIP > 0
+%      THEN \begingroup
+%              STYLE
+%              \@hangfrom{\hskip INDENT\@svsec}
+%              {\interlinepenalty 10000 ARG2\par}
+%           \endgroup
+%           \NAMEmark{ARG1}
+%           \addcontentsline{toc}{NAME}
+%              { IF  LEVEL > \c@secnumdepth
+%                  ELSE \protect\numberline{\theNAME}  FI
+%                ARG1 }
+%      ELSE \@svsechd == BEGIN  STYLE
+%                               \hskip INDENT\@svsec
+%                               ARG2
+%                               \NAMEmark{ARG1}
+%                               \addcontentsline{toc}{NAME}
+%                                  { IF  LEVEL > \c@secnumdepth
+%                                      ELSE 
+%                                        \protect\numberline{\theNAME}
+%                                      FI
+%                                    ARG1 }
+%                        END
+%    FI
+%    \@xsect{AFTERSKIP}
+% END
+%    \end{macrocode}
+% (\file{ltsect.dtx}, L295).
 %    \begin{macrocode}
-\renewcommand\listtablename{List of Tables}
+\def\@sect#1#2#3#4#5#6[#7]#8{%
+  \ifnum #2>\c@secnumdepth
+    \let\@svsec\@empty
+  \else
+    \refstepcounter{#1}%
+    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
+  \fi
+  \@tempskipa #5\relax
+  \ifdim \@tempskipa>\z@
+    \begingroup
 %    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\listfigurename}
-% From the Manual 3.7 p10, ``The heading |List of Figures| must appear
-% at the top of the page.''
-% Override \cls{book}'s definition.
+% Here we deviate from \file{ltsect.dtx} to ensure single spacing for
+% the section title.
 %    \begin{macrocode}
-\renewcommand\listfigurename{List of Figures}
+    \begin{spacing}{\@ssp}
+      #6{%
+        \@hangfrom{\hskip #3\relax\@svsec}%
+          \interlinepenalty \@M #8\@@par}%
+    \end{spacing}
+    \endgroup
+    \csname #1mark\endcsname{#7}%
+    \addcontentsline{toc}{#1}{%
+      \ifnum #2>\c@secnumdepth \else
+        \protect\numberline{\csname the#1\endcsname}%
+      \fi
+      #7}%
+  \else
+    \def\@svsechd{%
+      #6{\hskip #3\relax
+      \@svsec #8}%
+      \csname #1mark\endcsname{#7}%
+      \addcontentsline{toc}{#1}{%
+        \ifnum #2>\c@secnumdepth \else
+          \protect\numberline{\csname the#1\endcsname}%
+        \fi
+        #7}}%
+  \fi
+  \@xsect{#5}}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\abstractname}
-% From the Manual 3.8 p10, ``The following heading must be centered at
-% the top of the first page: |Abstract|\ldots''
+%
+% \begin{macro}{\@ssect}
+% Pseudocode for the |\@ssect| command
+%     \begin{macrocode}
+% \@ssect{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}{ARG} ==
+%   BEGIN
+%    IF AFTERSKIP > 0
+%      THEN \begingroup
+%             STYLE
+%             \@hangfrom{\hskip INDENT}{\interlinepenalty 10000 ARG\par}
+%           \endgroup
+%      ELSE \@svsechd == BEGIN STYLE
+%                              \hskip INDENT
+%                              ARG
+%                        END
+%    FI
+%    \@xsect{AFTERSKIP}
+%   END
+%     \end{macrocode}
+% (\file{ltsect.dtx}, L521).
 %    \begin{macrocode}
-\newcommand\abstractname{Abstract}
+\def\@ssect#1#2#3#4#5{%
+  \@tempskipa #3\relax
+  \ifdim \@tempskipa>\z@
+    \begingroup
 %    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\bibname}
-% From the Manual 3.13 p12, ``The heading |Bibliography| (or
-% |List of References|) must appear at the top of first page.''
-% Override \cls{book}'s definition.
+% Here we deviate from \file{ltsect.dtx} to ensure single spacing for
+% the section title.
 %    \begin{macrocode}
-\renewcommand\bibname{Bibliography}
+    \begin{spacing}{\@ssp}
+      #4{%
+        \@hangfrom{\hskip #1}%
+          \interlinepenalty \@M #5\@@par}%
+    \endgroup
+    \end{spacing}
+  \else
+    \def\@svsechd{#4{\hskip #1\relax #5}}%
+  \fi
+  \@xsect{#3}}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\appendixname}
-% From the Manual 3.14 p12, ``Number the appendicies consecutively
-% either alphabetically or numerically (|Appendix A|, |Appendix B|\ldots
-% or |Appendix 1|, |Appendix 2|\ldots).''
-% Override \cls{book}'s definition.
+%
+%
+% \subsubsection{\file{ltbibl.dtx}}
+%
+% \DescribeMacro{\bibliography}
+% \DescribeEnv{thebibliography}
+% A bibliography is created by the |thebibliography| environment, which
+% generates a title such as ``Bibliography'', and a list of entries.
+% The \BibTeX\ program will create a file containing such an
+% environment, which will be read in by the |\bibliography| command.
+% With \BibTeX, the following commands will be used.
+%
+% The document class must define the thebibliography environment.  This
+% environment has a single argument, which is the widest bibliography
+% label-- e.g., if the [Knuth67] is the widest entry, then this
+% argument will be Knuth67.  The |\thebibliography| command must begin
+% a list  environment, which the |\endthebibliography| command ends.
+%
+% \begin{macro}{\bibliography}
+% |\bibliography|\marg{file1,file2,\ldots,filen} : specifies
+%   the bibdata files.  Writes a |\bibdata| entry on the |.aux| file
+%   and tries to read in |mainfile.bbl|.
+%
+% We don't need to change it, but it explains why we need to override
+% |thebibliography| even when we don't use it directly.
+% (\file{ltbibl.dtx}, L284).
 %    \begin{macrocode}
-\renewcommand\appendixname{Appendix}
+%\def\bibliography#1{%
+%  \if@filesw
+%    \immediate\write\@auxout{\string\bibdata{#1}}%
+%  \fi
+%  \@input@{\jobname.bbl}
+%}
 %    \end{macrocode}
 % \end{macro}
-% \begin{macro}{\vitaname}
-% From the Manual 3.15 p13, ``The heading |Vita| must appear at the
-% top of the page.''
+%
+%
+% \subsubsection{\file{ltoutput.dtx}}
+%
+% \begin{macro}{\DUT@clearpage}
+% \begin{macro}{\DUT@cleardoublepage}
+% Versions of |\clear*page| that only work when |\if@final| is true
+% (\file{ltoutput.dtx}, L877 and L904).
 %    \begin{macrocode}
-\newcommand\vitaname{Vita}
+\newcommand\DUT@clearpage{\if@final \clearpage \fi}
+\newcommand\DUT@cleardoublepage{\if@final \cleardoublepage \fi}
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\blankpage}
-% Insert a blank page without numbering (except in draft mode).
+% Add a useful extension to insert a blank page without numbering.
+% In draft mode, this macro is a no-op.
 %    \begin{macrocode}
 \newcommand\blankpage{%
   \if@final
-    \clearpage
+    \DUT@clearpage
     \thispagestyle{empty}
     \hphantom{0}
-    \clearpage
+    \DUT@clearpage
   \else\fi
 }
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{command}
+%   `\cs{set@lines@length}\marg{length}\marg{N}'
+% \end{command}
 % \begin{macro}{\set@lines@length}
-% Protecting against external |spacing| environments.  Requires
-% \pkg{calc} for the multiplication.
+% Many specifications in the Manual refer to ``\meta{N} blank lines''.
+% |\set@lines@length| allows you to set a length to a given number of
+% lines, protecting against external |spacing| environments.  It
+% requires \pkg{calc} for the multiplication.
 %    \begin{macrocode}
 \let\DUT@baselineskip\baselineskip
 \newcommand{\set@lines@length}[2]{%
 }
 %    \end{macrocode}
 % \end{macro}
+%
+% \begin{command}
+%   `\cs{blanklines}\marg{N}'
+% \end{command}
 % \begin{macro}{\blanklines}
-% Insert number of blank lines.
+% Insert \meta{N} blank lines.
 %    \begin{macrocode}
 \newlength\DUT@blanklines@length
 \newcommand{\blanklines}[1]{%
 %    \end{macrocode}
 % \end{macro}
 %
+%
+% \subsection{\cls{book} overrides and extensions}
+%
+% Here we change the behavior of a bunch of macros and environments from
+% \cls{book} (generated by \file{classes.ins} from \file{classes.dtx}) in
+% \href{http://www.ctan.org/tex-archive/macros/latex/base/}{\pkg{base}}).
+% We'll copy in their original notes along with their code, following
+% the relevant documentation an order given in \file{classes.dtx}.
+%
+%
+% \subsubsection{Floats on a text page}
+%
+% \begin{macro}{\floatsep}
+% \begin{macro}{\textfloatsep}
+% \begin{macro}{\intextsep}
+% When a floating object is placed on a page with text, these
+% parameters control the separation between the float and the other
+% objects on the page.
+%
+% |\floatsep| is the space between adjacent floats that are moved
+% to the top or bottom of the text page.
+%
+% |\textfloatsep| is the space between the main text and floats
+% at the top or bottom of the page.
+%
+% |\intextsep| is the space between in-text floats and the text.
+%
+% From the Manual 2.3 p6, ``Tables and Figures''
+% \begin{quote}
+%   Insert at least 3 single-spaced lines of space above table
+%   captions and figures and below figure captions, tables, and other
+%   graphics.
+% \end{quote}
+% (\file{classes.dtx}, L1426)
+%    \begin{macrocode}
+\set@lines@length{\floatsep}{\@ssp}
+\set@lines@length{\textfloatsep}{\@tsp}
+\set@lines@length{\intextsep}{\@tsp}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsubsection{The title}
+%
 % \begin{macro}{\maketitle}
 % Automate the creation of the title page.
 % From Manual 3.1 p8, ``Title Page'', and the example on p16.
 %   \item This page is counted but not numbered (it counts as page i,
 %   but should not have a page number).  TODO: How is this implemented?
 % \end{itemize}
-% Override \cls{book}'s definition.
+% Our definition simplifies \cls{book}'s by ignoring footnotes.
+% (\file{classes.dtx}, L1796)
 %    \begin{macrocode}
 \renewcommand\maketitle{
-  \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
-  \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
-  \long\def\@makefntext##1{\parindent 1em\noindent
-       \hb@xt@1.8em{%
-       \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
   \begin{titlepage}%
+%    \end{macrocode}
+% Add some bookmarks if we're using pdf\LaTeX.  The |frontmatter|
+% bookmark is set at the \emph{part} level (-1) to hold all bookmarks
+% from the |preamble| environment, since those entries are all
+% chapters.
+%    \begin{macrocode}
     \ifpdf
       \pdfbookmark[-1]{Frontmatter}{frontmatter}
       \pdfbookmark[0]{Title Page}{title}
     \fi
-    \vspace*{\fill}
+%    \end{macrocode}
+% Add some stretchy space to center the title vertically if we're not
+% in draft mode.
+%    \begin{macrocode}
+    \if@final \vspace*{\fill} \fi
+%    \end{macrocode}
+% Here is the title text itself.
+%    \begin{macrocode}
     \begin{center}%
     \begin{spacing}{\@tsp}
       {\bf \@title \par}%
       \def@month\ \def@year
     \end{spacing}
     \end{center}\par
-    \vspace*{\fill}
-  \end{titlepage}%
-  \setcounter{footnote}{0}%
+%    \end{macrocode}
+% Some more stretchy space for the bottom if we're not in draft mode.
+%    \begin{macrocode}
+%    \end{macrocode}
+% Add some stretchy space to center the title vertically if we're not
+% in draft mode.
+%    \begin{macrocode}
+    \if@final \vspace*{\fill} \fi
+  \end{titlepage}%
+%    \end{macrocode}
+% And that's it.  We reset the footnote counter for the rest of the
+% document and save space by freeing the memory associated with the
+% |\maketitle| and |\and| macros (by setting them equal to |\relax|).
+%    \begin{macrocode}
+  \setcounter{footnote}{0}%
   \global\let\maketitle\relax
   \global\let\and\relax
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\m@kecopyright}
-% Automate the creation of the copyright page.
+%
+% \subsubsection{Copyright pages}
+% \label{sec:implement-copyright}
+%
+% \begin{macro}{\makecopyright}
+% The Manual allows for the selection of different copyrights, so we
+% define a base macro that generates a proper copyright page
+% containing |\@copyrighttext|, which the user can set with
+% |\copyrighttext|.
 % From Manual 3.2 p9, ``Copyright Page''.
 % \begin{itemize}
 %   \item Include a copyright page with the following information: a
 %   publication on file.
 %   \item This page is neither counted nor numbered.
 % \end{itemize}
+% In final mode, we start off on a new page and center the blurb.
+% In draft mode, we dive right into the text.
+%    \begin{macrocode}
+\newcommand\makecopyright{%
+  \DUT@clearpage
+%    \end{macrocode}
+% If we're using pdf\LaTeX, add a bookmark.
 %    \begin{macrocode}
-\newcommand\m@kecopyright[1]{%
-  \clearpage
   \ifpdf \pdfbookmark[0]{Copyright Page}{copyright} \fi
-  \vspace*{\fill}
+  \if@final \vspace*{\fill} \fi
   \begin{center}
     \copyright~Copyright \def@year\\
-    \@author.  #1
+    \@author.  \@copyrighttext
   \end{center}
-  \vspace*{\fill}
+  \if@final \vspace*{\fill} \else \blanklines{2} \fi
 %    \end{macrocode}
-% |\thispagestyle{empty}| turns off page numbering for the current
-% page.  See
-% \href{http://www.personal.ceu.hu/tex/pagestyl.htm#pgstyle}{here}.
+% Turn off page numbering for this page.
 %    \begin{macrocode}
   \thispagestyle{empty}
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\makecopyright}
+% \begin{macro}{\copyrighttextCC}
+% The Creative Commons license.
 %    \begin{macrocode}
-\newcommand\makecopyright{%
-  \m@kecopyright{All Rights Reserved.}
+\newcommand\copyrighttextCC{
+  \begin{quote}
+    This work is licensed under the terms of the Creative Commons
+    Attribution-ShareAlike license.  The license is available at \\
+    \url{http://creativecommons.org/licenses/by-sa/2.0/}.
+  \end{quote}
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\makecopyrightCC}
+%
+% \subsubsection{Mark commands}
+%
+% Default initializations of |\...mark| commands.  These commands
+% are used in the definition of the page styles.
+%
+% \begin{macro}{\chaptermark}
+% Setup colon rather than period separated chapter marks.
+% (\file{classes.dtx}, L2053)
+%    \begin{macrocode}
+\renewcommand\chaptermark[1]{%
+  \markboth {\MakeUppercase{%
+    \ifnum \c@secnumdepth >\m@ne
+      \if@mainmatter
+        \@chapapp\ \thechapter: \ %
+      \fi
+    \fi
+    #1}}{}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\chaptermark}
+% Setup space rather than period separated section marks.
+% (\file{classes.dtx}, L2054)
+%    \begin{macrocode}
+\renewcommand{\sectionmark}[1]{%
+  \markright {\MakeUppercase{%
+    \ifnum \c@secnumdepth >\z@
+      \thesection \ %
+    \fi
+    #1}}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Front Matter, Main Matter, and Back Matter}
+%
+% A book contains these three (logical) sections. The switch
+% |\@mainmatter| is true iff we are processing Main Matter.  When this
+% switch is false, the |\chapter| command does not print chapter
+% numbers.
+%
+% \begin{macro}{\mainmatter}
+% This command clears the page (in final mode), starts arabic page
+% numbering and turns on chapter numbering.  Since this restarts the
+% page numbering from 1, it should also ensure that a recto page is
+% used.
+%
+% We replace \cls{book}'s |\clear*page| calls with |\DUT@clearpage| calls.
+% (\file{classes.dtx}, L2211)
+%    \begin{macrocode}
+\renewcommand\mainmatter{%
+  \DUT@cleardoublepage
+  \@mainmattertrue
+  \pagenumbering{arabic}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Parts}
+%
+% \begin{macro}{\part}
+% The command to start a new part of our document.
+%
+% We start a new (righthand) page and use the \pstyle{plain}
+% pagestyle, replacing \cls{book}'s |\clear*page| calls with
+% |\DUT@clearpage| calls and dropping twopage code.
+% (\file{classes.dtx}, L2249)
+%    \begin{macrocode}
+\renewcommand\part{%
+  \if@openright
+    \DUT@cleardoublepage
+  \else
+    \DUT@clearpage
+  \fi
+  \thispagestyle{plain}%
+  \@tempswafalse
+%    \end{macrocode}
+% Add some stretchy space for vertical centering if we're in final mode.
+%    \begin{macrocode}
+  \if@final \null\vfil \fi
+%    \end{macrocode}
+% Here we use |\secdef| to indicate which commands to use to make
+% the actual heading.
+%    \begin{macrocode}
+  \secdef\@part\@spart}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@part}
+% This macro does the actual formatting of the title of the part.  We
+% replace \cls{book}'s |\Huge| with |\large|, and make use of
+% |\numberline| for consistent spacing.
+%
+% When \Lcount{secnumdepth} is larger than $-2$, we have a numbered
+% part, otherwise it is unnumbered.
+% (\file{classes.dtx}, L2310)
+%    \begin{macrocode}
+\def\@part[#1]#2{%
+    \ifnum \c@secnumdepth >-2\relax
+      \refstepcounter{part}%
+      \AddContentsLine{toc}{part}%
+        {\protect\numberline{\thepart}}{#1}%
+    \else
+      \AddContentsLine{toc}{part}{}{#1}%
+    \fi
+%    \end{macrocode}
+% We empty the mark registers and center the title on the page.
+% Also we prevent breaking between lines and reset the font.
+%    \begin{macrocode}
+    \markboth{}{}%
+    {\centering
+     \interlinepenalty \@M
+     \normalfont
+%    \end{macrocode}
+% When this is a numbered part we have to print the number.
+%    \begin{macrocode}
+     \ifnum \c@secnumdepth >-2\relax
+       \large\bfseries \partname\nobreakspace\thepart
+       \par
+%    \end{macrocode}
+% We leave some space before we print the title and leave the
+% finishing up to |\@endpart|.
+%    \begin{macrocode}
+       \vskip 20\p@
+     \fi
+     \large \bfseries #2\par}%
+    \@endpart}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@spart}
+% This macro does the actual formatting of the title of the part
+% when the star form of the user command was used. In this case we
+% \emph{never} print a number. Otherwise the formatting is the
+% same.
+% (\file{classes.dtx}, L2402)
+%    \begin{macrocode}
+\def\@spart#1{%
+    {\centering
+     \interlinepenalty \@M
+     \normalfont
+     \large \bfseries #1\par}%
+    \@endpart}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@endpart}
+% This macro finishes the part page, for both |\@part| and |\@spart|.
+% We drop \cls{book}'s twoside handling.
+% If |\if@final| is true, we fill the current page.
+% (\file{classes.dtx}, L2435)
+%    \begin{macrocode}
+\def\@endpart{
+  \if@final \vfil\newpage \fi
+%    \end{macrocode}
+% Then, when we are in twosided mode and the chapters are supposed to
+% be on the right hand sides, we produce a completely blank page.  We
+% don't need to check |\if@final| here, because \Lopt{draftspace} set
+% |\@openrighttrue|.
+%    \begin{macrocode}
+  \if@twoside
+    \if@openright
+      \null
+      \thispagestyle{empty}%
+      \newpage
+    \fi
+  \fi}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Chapters}
+% \label{sec:implement-chapters}
+%
+% \begin{macro}{\chapter}
+% \cls{book} always starts a chapter on a new page, but we don't want
+% to do that if we're in draft mode.
+% (\file{classes.dtx}, L2472).
+%    \begin{macrocode}
+\renewcommand\chapter{%
+  \if@openright\DUT@cleardoublepage\else\DUT@clearpage\fi
+  \thispagestyle{plain}%
+%    \end{macrocode}
+% Then we prevent floats from appearing at the top of this page
+% because it looks weird to see a floating object above a chapter
+% title.
+%    \begin{macrocode}
+  \global\@topnum\z@
+%    \end{macrocode}
+% Then we suppress the indentation of the first paragraph by
+% setting the switch |\@afterindent| to false. We use |\secdef|
+% to specify the macros to use for actually setting the chapter
+% title.
+%    \begin{macrocode}
+  \@afterindentfalse
+  \secdef\@chapter\@schapter}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@chapter}
+% This macro is called when we have a numbered chapter. When
+% \Lcount{secnumdepth} is larger than $-1$ and |\@mainmatter| is true,
+% we display the chapter number.
+% We drop \cls{book}'s \Lopt{twocolumn} code. 
+% (\file{classes.dtx}, L2496).
+% \begin{macrocode}
+\def\@chapter[#1]#2{
+  \ifnum \c@secnumdepth >\m@ne
+    \if@mainmatter
+      \refstepcounter{chapter}%
+% \end{macrocode}
+% Inform the user that a new chapter is about to be typeset by writing
+% a message to the terminal.
+% \begin{macrocode}
+      \typeout{\@chapapp\space\thechapter.}%
+      \if@appendix
+% \end{macrocode}
+% We're in the appendix (when |\if@mainmatter| and
+% |\if@appendix| are both true), add a TOC line like
+% \begin{center}
+%   Appendix A: Chapter Title
+% \end{center}
+% |\thechapter| (defined in \cls{book}) is the text representation of 
+% the chapter number (e.g.\ |1| or, for an appendix, |A|).
+% |\@chapapp{}| (also defined in \cls{book}) was redefined in
+% |\appendix| (Sec. \ref{sec:implement-appendix}) as |\appendixname|.
+% \begin{macrocode}
+        \AddContentsLine{toc}{appendix}%
+          {\protect\numberline{\@chapapp{} \thechapter:}}{#1}%
+      \else
+% \end{macrocode}
+% We're in the pre-appendix mainmatter, so add a TOC line like
+% \begin{center}
+%   1 Chapter Title
+% \end{center}
+% \begin{macrocode}
+        \AddContentsLine{toc}{chapter}%
+          {\protect\numberline{\thechapter}}{#1}%
+      \fi
+    \else
+% \end{macrocode}
+% We're in the pre-mainmatter, so add a TOC line like
+% \begin{center}
+%   Chapter Title
+% \end{center}
+% \begin{macrocode}
+      \AddContentsLine{toc}{chapter}{}{#1}%
+    \fi
+  \else
+    \AddContentsLine{toc}{chapter}{}{#1}%
+  \fi
+%    \end{macrocode}
+% After having written an entry to the table of contents we store
+% the (alternative) title of this chapter with |\chaptermark| and
+% add some white space to the lists of figures and tables.
+%    \begin{macrocode}
+  \chaptermark{#1}%
+  \addtocontents{lof}{\protect\addvspace{10\p@}}%
+  \addtocontents{lot}{\protect\addvspace{10\p@}}%
+%    \end{macrocode}
+% Then we call upon |\@makechapterhead| to format the actual chapter
+% title.  |\@afterheading| which takes care of suppressing the
+% indentation.
+%    \begin{macrocode}
+  \@makechapterhead{#2}%
+  \@afterheading}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makechapterhead}
+% The |\@chapter| macro uses |\@makechapterhead|\meta{text} to format
+% the heading of the chapter.
+% From the Manual 3.11 p11.
+% \begin{quote}
+%   Chapter headings must be bold and centered.
+%   The chapter number and title must be on the same line, separated
+%   by a colon or period, as shown in the example below:
+%   \begin{center}
+%     CHAPTER 1: INTRODUCTION
+%   \end{center}
+%   Headings must not be larger than 12 points.
+%   Headings must be single spaced.
+% \end{quote}
+% \cls{book} sets |\@chapapp| and |\thechapter| (e.g.\ ``Chapter 5'')
+% on a line above the chapter title, but that doesn't match the
+% Manual's specification.
+%
+% We begin by leaving some white space. The we open a group in which
+% we have a paragraph indent of 0pt, and in which we have the text set
+% ragged right. We also reset the font.
+% (\file{classes.dtx}, L2540).
+%    \begin{macrocode}
+\def\@makechapterhead#1{%
+  \blanklines{2}%
+  {\parindent \z@ \raggedright \normalfont
+%    \end{macrocode}
+% Ensure single spacing.
+%    \begin{macrocode}
+    \begin{spacing}{\@ssp}
+%    \end{macrocode}
+% Prevent a pagebreak from occuring in the middle of or after the title.
+%    \begin{macrocode}
+    \interlinepenalty\@M
+%    \end{macrocode}
+% Check whether the number of the chapter has to be printed.
+%    \begin{macrocode}
+    \ifnum \c@secnumdepth >\m@ne
+%    \end{macrocode}
+% Check whether there \emph{is} a number to be printed.
 %    \begin{macrocode}
-\newcommand\makecopyrightCC{
-  \m@kecopyright{
-    \begin{quote}
-      This work is licensed under the terms of the Creative Commons
-      Attribution-ShareAlike license.  The license is available at \\
-      \url{http://creativecommons.org/licenses/by-sa/2.0/}.
-    \end{quote}
+      \if@mainmatter
+%    \end{macrocode}
+% Setup a ``Chapter \#: Title'' heading.
+%    \begin{macrocode}
+        \center \large \bfseries \@chapapp{} \thechapter: #1\par\nobreak
+      \else
+%    \end{macrocode}
+% Setup a ``Title'' heading.
+%    \begin{macrocode}
+        \center \large \bfseries #1\par\nobreak
+      \fi
+    \else
+      \center \large \bfseries #1\par\nobreak
+    \fi
+    \end{spacing}
+%    \end{macrocode}
+% Put a little space before the chapter body.
+%    \begin{macrocode}
+    \blanklines{2}
   }
 }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\tableofcontents}
-% Automate the creation of the table of contents.
-% From Manual 3.5 p9, ``Table of Contents'', and the example on p17.
-% \begin{itemize}
-%   \item Do not list any sections that precede the
-%   |Table of Contents| (e.g.\ |Dedications|, |Acknowledgments|).  Do
-%   not list the |Table of Contents| itself.
-%   \item These pages are counted and numbered in lowercase Roman numerals.
-% \end{itemize}
-% Override \cls{book}'s definition.
+% \begin{macro}{\@schapter}
+% We don't have to worry about |\@schapter|, since it is very simple.
+% In onecolumn mode it's just
+% (\file{classes.dtx}, L2582).
 %    \begin{macrocode}
-\renewcommand\tableofcontents{%
-  \clearpage
-  \ifpdf
-    \phantomsection
-    \pdfbookmark[0]{\contentsname}{tableofcontents}
-  \fi
-  \chapter*{\contentsname}
-  \@mkboth{\MakeUppercase\contentsname}%
-          {\MakeUppercase\contentsname}%
-  \@starttoc{toc}%
+%\def\@schapter#1{\@makeschapterhead{#1}%
+%                 \@afterheading}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makeschapterhead}
+% The macro above uses |\@makeschapterhead|\meta{text} to format
+% the heading of the chapter. It is similar to |\@makechapterhead|
+% except that it never has to print a chapter number.
+% (\file{classes.dtx}, L2595).
+%    \begin{macrocode}
+\def\@makeschapterhead#1{%
+  \blanklines{2}%
+  {\parindent \z@ \raggedright
+    \normalfont
+    \interlinepenalty\@M
+    \begin{spacing}{\@ssp}
+    \center \large \bfseries  #1\par\nobreak
+    \end{spacing}
+    \blanklines{2}
+  }
 }
 %    \end{macrocode}
 % \end{macro}
 %
 %
-% \subsection{Environments}
+% \begin{macro}{\toclevel@appendix}
+% We've added a new TOC entry type with the
+% \begin{example} 
+%   \AddContentsLine{toc}{appendix}{...}{...}
+% \end{example}
+% calls above, and \pkg{hyperref} needs to know what level they belong
+% to.  Obviously they belong to the chapter level ($0$).
+%    \begin{macrocode}
+\providecommand*{\toclevel@appendix}{0}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Lower level headings}
+%
+% \begin{macro}{\section}
+% Setup section headings in |\large| rather than \cls{book}'s
+% |\Large|.
+% (\file{classes.dtx}, L2623).
+%    \begin{macrocode}
+\renewcommand\section{%
+  \@startsection {section}{1}{\z@}%
+    {-3.5ex \@plus -1ex \@minus -.2ex}%
+    {2.3ex \@plus.2ex}%
+    {\normalfont\large\bfseries}}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \subsubsection{Defining new environments}
+%
+% We don't override any of \cls{book}'s environments, but this is
+% where \file{classes.dtx} defines its environments (L2996), so we'll put
+% ours here too.
 %
 % \begin{environment}{preamble}
 %    \begin{macrocode}
 % \end{itemize}
 %    \begin{macrocode}
 \newenvironment{dedications}{%
-  \clearpage
+  \DUT@clearpage
   \ifpdf
     \phantomsection
     \pdfbookmark[0]{\dedicationsname}{dedications}
 % \end{itemize}
 %    \begin{macrocode}
 \newenvironment{acknowledgments}{%
-  \clearpage
+  \DUT@clearpage
   \ifpdf
     \phantomsection
     \pdfbookmark[0]{\acknowledgmentsname}{acknowledgments}
 % \begin{environment}{abstract}
 %    \begin{macrocode}
 \newenvironment{abstract}{%
-  \clearpage
+  \DUT@clearpage
   \thispagestyle{plain}%
   \global\@topnum\z@
   \phantomsection
-  \addcontentsline{toc}{chapter}{\abstractname}
+  \AddContentsLine*{toc}{chapter}{}{\abstractname}
   \vspace*{50\p@}%
 %    \end{macrocode}
 % From the Manual 3.9 p10 ``The following heading must be centered at
   \begin{spacing}{\@dsp}
 }{%
   \end{spacing}
-  \clearpage
+  \DUT@clearpage
   \ifpdf
     \phantomsection
     \pdfbookmark[-1]{Backmatter}{backmatter}
 % \end{itemize}
 %    \begin{macrocode}
 \newenvironment{vita}{%
-  \clearpage
+  \DUT@clearpage
   \phantomsection
-  \addcontentsline{toc}{chapter}{\vitaname}
+  \AddContentsLine*{toc}{chapter}{}{\vitaname}
   \chapter*{\vitaname}
   \blanklines{1}
   \begin{spacing}{\@dsp}
 % \end{environment}
 %
 %
-% \subsection{Adjust from the \LaTeX/\cls{book} defaults}
-%
+% \subsubsection{Titlepage}
 %
-% \subsubsection{Part and chapter headings}
-%
-% Override \cls{book}'s |\makechapterhead|.
-% From the Manual 3.11 p11.
-% \begin{quote}
-%   Chapter headings must be bold and centered.
-%   The chapter number and title must be on the same line, separated
-%   by a colon or period, as shown in the example below:
-%   \begin{center}
-%     CHAPTER 1: INTRODUCTION
-%   \end{center}
-%   Headings must not be larger than 12 points.
-%   Headings must be single spaced.
-% \end{quote}
-%    \begin{macrocode}
-\def\@makechapterhead#1{%
-  \vspace*{50\p@}%
-%    \end{macrocode}
-% Replaced |\normalfont| with |\reset@font| (TODO: why?).
+% \begin{environment}{titlepage}
+% In the normal environments, the titlepage environment does nothing
+% but start and end a page, and inhibit page numbers.  We inhibit the
+% paging in draft mode, since it seems silly to waste a whole page on
+% the title.  We also drop the \Lopt{twocolumn} code.
+% (\file{classes.dtx}, L3111)
 %    \begin{macrocode}
-  {\parindent \z@ \raggedright \reset@font
-    \ifnum \c@secnumdepth >\m@ne
+\renewenvironment{titlepage}{\thispagestyle{empty}%
+                             \setcounter{page}\z@}%
+                            {\if@final \newpage \else \blanklines{2} \fi}
 %    \end{macrocode}
-% Removed |\if@mainmatter| conditional guarding this indented section
-% (TODO: why?).
+% \end{environment}
+%
+%
+% \subsubsection{Appendix}
+%
+% \begin{macro}{\appendix}
+% The |\appendix| command is not really an environment, it is a
+% macro that makes some changes in the way things are done.
+%
+% In the article document class the |\appendix| command must do the
+% following:
+% \begin{itemize}
+%   \item reset the section and subsection counters to zero,
+%   \item redefine |\thesection| to produce alphabetic appendix
+%         numbers. This redefinition is done globally to ensure that it 
+%         survives even if |\appendix| is issued within an environment such
+%         as \texttt{multicols}.
+% \end{itemize}
+%
+% In addition to \cls{book}'s (or \pkg{hyperref}'s) activity, we add
+% |\@appendixtrue|.  This gets |\if@appendix| working in our
+% |\chapter| definition (Sec.~\ref{sec:implement-chapters}).
+% (\file{classes.dtx}, L3177)
 %    \begin{macrocode}
-        \par\nobreak
-        \vskip 20\p@
-    \fi
-    \interlinepenalty\@M
+\let\DUT@appendix\appendix
+\renewcommand\appendix{%
+  \@appendixtrue%
+  \DUT@appendix%
 %    \end{macrocode}
-% Ensure single spacing, and ensure the chapter heading will have a
-% centered, |\large|, bold \emph{Chapter \#: Title} or \emph{Appendix
-% \#: Title} format (as opposed to \cls{book}'s unaligned, |\Huge|,
-% bold \emph{Title}).
+% We also turn on double spacing by default, since we're no longer
+% wrapped in the |thesis| environment.
 %    \begin{macrocode}
-    \begin{spacing}{\@ssp}
-    \center \large \bfseries \@chapapp{} \thechapter: #1\par\nobreak
-    \blanklines{2}
-    \end{spacing}
-  }
+  \setstretch{\@dsp}
 }
 %    \end{macrocode}
+% \end{macro}
+%
 %
-% Override \cls{book}'s |\@makeschapterhead|.  TODO: Why?
+% \subsubsection{Table}
+% \label{sec:implement-tables}
+%
+% \begin{environment}{table}
+% \begin{environment}{table*}
+% To help symmetrize the spacing around tables and figures, we set
+% |\if@table| in the |table| environments.  The remainder of the
+% code comes in Section \ref{sec:implement-captions}.
+% (\file{classes.dtx}, L3491)
 %    \begin{macrocode}
-\def\@makeschapterhead#1{%
-  \vspace*{50\p@}%
-   {\parindent \z@ \raggedright
+\newif\if@table \@tablefalse
+\renewenvironment{table}
+                 {\@tabletrue\@float{table}}
+                 {\end@float\@tablefalse}
+\renewenvironment{table*}
+                 {\@tabletrue\@dblfloat{table}}
+                 {\end@dblfloat\@tablefalse}
 %    \end{macrocode}
-% Replaced |\normalfont| with |\reset@font| (TODO: why?).
+% \end{environment}
+% \end{environment}
+%
+%
+% \subsubsection{Captions}
+% \label{sec:implement-captions}
+%
+% \begin{macro}{\@makecaption}
+% The |\caption| command calls |\@makecaption| to format the
+% caption of floating objects. It gets two arguments,
+% \meta{number}, the number of the floating object and \meta{text},
+% the text of the caption. Usually \meta{number} contains a string
+% such as ``Figure 3.2''. The macro can assume it is called inside a
+% |\parbox| of right width, with |\normalsize|.
+%
+% We override \cls{book}'s |\@makecaption|, adding two |\if@table|
+% conditionals, which swap |\abovecaptionskip| and |\belowcaptionskip|
+% for tables (where the caption is above the float body).  With our
+% implementation, |\belowcaptionskip| \emph{always} gives the distance
+% between the caption and the text, and |\abovecaptionskip|
+% \emph{always} gives the distance between the caption and the float
+% body.  See Section \ref{sec:implement-tables} for our |\if@table|
+% control.
+%
+% We also replace the caption lead-in |#1: #2| with
+% |\small{\bfseries#1:} #2|.
+% (\file{classes.dtx}, L3508)
 %    \begin{macrocode}
-    \reset@font
-    \interlinepenalty\@M
 %    \end{macrocode}
-% Ensure single spacing.
+% Define a temporary length for swapping.
 %    \begin{macrocode}
-    \begin{spacing}{\@ssp}
+\newlength\@tempcapskip
 %    \end{macrocode}
-% Replaced |\Huge| with |\center \large|
+% The definition of this macro is |\long| in order to allow more
+% then one paragraph in a caption.
 %    \begin{macrocode}
-    \center \large \bfseries  #1\par\nobreak
+\long\def\@makecaption#1#2{%
+  \if@table
 %    \end{macrocode}
-% Replaced |\vskip 40\p@| with |\blanklines{2}|
+% Swap |\abovecaptionskip| and |\belowcaptionskip|.
 %    \begin{macrocode}
-    \blanklines{2}
-    \end{spacing}
-  }
+    \@tempcapskip\abovecaptionskip
+    \abovecaptionskip\belowcaptionskip
+    \belowcaptionskip\@tempcapskip
+  \fi
+  \vskip\abovecaptionskip
+%    \end{macrocode}
+% We want to see if the caption fits on one line on the page,
+% therefore we first typeset it in a temporary box.
+%    \begin{macrocode}
+  \sbox\@tempboxa{\small{\bfseries#1:} #2}%
+%    \end{macrocode}
+% We can the measure its width. It that is larger than the current
+% |\hsize| we typeset the caption as an ordinary paragraph.
+%    \begin{macrocode}
+  \ifdim \wd\@tempboxa >\hsize
+    {\small{\bfseries#1:} #2\par}
+  \else
+%    \end{macrocode}
+% If the caption fits, we center it. Because this uses an |\hbox|
+% directly in vertical mode, it does not execute the |\everypar|
+% tokens; the only thing that could be needed here is resetting the
+% `minipage flag' so we do this explicitly.
+%    \begin{macrocode}
+    \global \@minipagefalse
+    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
+  \fi
+  \vskip\belowcaptionskip
+%    \end{macrocode}
+% Restore |\abovecaptionskip| and |\belowcaptionskip|.
+%    \begin{macrocode}
+  \if@table
+    \@tempcapskip\belowcaptionskip
+    \belowcaptionskip\abovecaptionskip
+    \abovecaptionskip\@tempcapskip
+  \fi
 }
 %    \end{macrocode}
+% \end{macro}
 %
-% Override \cls{book}'s |\section|, replacing |\Large| with |\large|.
+% \begin{macro}{\abovecaptionskip}
+% \begin{macro}{\belowcaptionskip}
+% For \cls{book}, these lengths contain the amount of white space to
+% leave above and below the caption.  However, because of our work
+% with |\@makecaption| (above), |\belowcaptionskip| \emph{always}
+% gives the distance between the caption and the text, and
+% |\abovecaptionskip| \emph{always} gives the distance between the
+% caption and the float.
+% (\file{classes.dtx}, L3516)
 %    \begin{macrocode}
-\renewcommand\section{\@startsection {section}{1}{\z@}%
-                                     {-3.5ex \@plus -1ex \@minus -.2ex}%
-                                     {2.3ex \@plus.2ex}%
-                                     {\normalfont\large\bfseries}}
+\set@lines@length{\abovecaptionskip}{\@ssp}
+\set@lines@length{\belowcaptionskip}{\@tsp}
 %    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsubsection{Table of Contents}
+%
+% \begin{macro}{\tableofcontents}
+% Automate the creation of the table of contents.
+% From Manual 3.5 p9, ``Table of Contents'', and the example on p17.
+% \begin{itemize}
+%   \item Do not list any sections that precede the
+%   |Table of Contents| (e.g.\ |Dedications|, |Acknowledgments|).  Do
+%   not list the |Table of Contents| itself.
+%   \item These pages are counted and numbered in lowercase Roman numerals.
+% \end{itemize}
+% We inhibit the paging in draft mode and drop the \Lopt{twocolumn} code.
+% (\file{classes.dtx}, L3728)
+%    \begin{macrocode}
+\renewcommand\tableofcontents{%
+  \DUT@clearpage
+%    \end{macrocode}
+% If we're using pdf\LaTeX, add a bookmark.
+%    \begin{macrocode}
+  \ifpdf
+    \phantomsection
+    \pdfbookmark[0]{\contentsname}{tableofcontents}
+  \fi
+  \chapter*{\contentsname}
+%    \end{macrocode}
+% Set the marks for \cls{fancyhdr}'s fancy header.
+%    \begin{macrocode}
+  \@mkboth{\MakeUppercase\contentsname}%
+          {\MakeUppercase\contentsname}%
+  \@starttoc{toc}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% The command |\contentsline{|\meta{name}|}| expands to
+% |\l@|\meta{name}.  So, to specify the table of contents, we must
+% define |\l@chapter|, |\l@section|, |\l@subsection|, ... ; to
+% specify the list of figures, we must define |\l@figure|; and so
+% on.
 %
-% Fix |\@ssect| and |\@sect| from |latex.ltx| to give single spaced
-% headings.  These macros are defined in |ltsect.dtx|
-% (\href{http://www.ctan.org/tex-archive/macros/latex/base/}{\pkg{\LaTeX\ base}})),
-% but the documentation there is not great.
 % \begin{command}
-%    `\cs{@ssect}\bracearg{INDENT}\bracearg{BEFORESKIP}\bracearg{AFTERSKIP}'
-%    `~~\bracearg{STYLE}\bracearg{ARG}'
-%    `\cs{@sect}\bracearg{NAME}\bracearg{LEVEL}\bracearg{INDENT}\bracearg{BEFORESKIP}'
-%    `~~\bracearg{AFTERSKIP}\bracearg{STYLE}\brackarg{ARG1}\bracearg{ARG2}'
+%   `\cs{l@DUT@major}\marg{title}\marg{page}\marg{inset}'
 % \end{command}
-% By comparison to \cls{book}'s |\@part| and |\@spart| (see below), I
-% imagine they have something to do with formatting section names.
+% \begin{macro}{\l@DUT@major}
+% Define a wrapper class for printing TOC entries for parts, chapters,
+% and appendicies, since they should all have the same formatting.
+% \meta{title} and \meta{page} are the first two arguments passed to
+% the outer |\l@*| macro.  \meta{inset} gives the distance that the
+% title text is offset from the left margin (|\@tempdima|), with any
+% |\numberline| text (e.g.\ part or chapter numbers) being printed
+% flush on the left margin.
+%    \begin{macrocode}
+\newif\if@bold@DUT@major
+\newif\if@dotted@DUT@major
+\newcommand\l@DUT@major[3]{%
+  \begin{spacing}{\@ssp}
+    \ifnum \c@tocdepth >\m@ne
+%    \end{macrocode}
+% Make sure that if a pagebreak should occur, it occurs \emph{before}
+% this entry.
 %    \begin{macrocode}
-\def\@ssect#1#2#3#4#5{%
-  \@tempskipa #3\relax
-  \ifdim \@tempskipa>\z@
-    \begingroup
-    \begin{spacing}{\@ssp}
-      #4{%
-        \@hangfrom{\hskip #1}%
-          \interlinepenalty \@M #5\@@par}%
-    \endgroup
-    \end{spacing}
+      \addpenalty{-\@highpenalty}%
+%    \end{macrocode}
+% The macro |\numberline| requires that the width of the box that
+% holds the part number is stored in \LaTeX's scratch register
+% |\@tempdima|. Therefore we initialize it there even though we may
+% not use |\numberline| internally.
+%    \begin{macrocode}
+      \setlength\@tempdima{#3}%
+      \begingroup
+%    \end{macrocode}
+% We set |\parindent| to 0pt and use |\rightskip| to leave
+% enough room for the pagenumbers.\footnote{^^A
+%   We use \file{classes.dtx} suggested \cs{@tocrmarg} for
+%   \cs{rightskip}, which they're delaying until \LaTeX3.}
+% To prevent overfull box messages the |\parfillskip| is set to a 
+% negative value.
+%    \begin{macrocode}
+        \parindent \z@ \rightskip \@tocrmarg \parfillskip -\rightskip
+%    \end{macrocode}
+% Leave vertical mode.
+%    \begin{macrocode}
+        \leavevmode
+%    \end{macrocode}
+% Switch to bold font if appropriate.
+%    \begin{macrocode}
+        \if@bold@DUT@major
+          \bfseries
+        \fi
+%    \end{macrocode}
+% Manuever to place the part number flush left, with the part title
+% inset by |\@tempdima|.
+%    \begin{macrocode}
+        \advance\leftskip\@tempdima
+        \hskip -\leftskip
+%    \end{macrocode}
+% Set the part title.
+%    \begin{macrocode}
+        #1\nobreak
+%    \end{macrocode}
+% Draw a dotted line if appropriate.
+%    \begin{macrocode}
+        \if@dotted@DUT@major
+          \leaders\hbox{$\m@th
+            \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}
+        \fi
+%    \end{macrocode}
+% Wrap up with the page entry, set flush right.
+%    \begin{macrocode}
+        \hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
+%    \end{macrocode}
+% Prevent a pagebreak immediately after this entry.
+%    \begin{macrocode}
+        \nobreak
+%    \end{macrocode}
+% Add a content-page-spacing blank after this entry.
+%    \begin{macrocode}
+        \blanklines{\@cont@sep}
+%    \end{macrocode}
+% Discourage page breaking.
+%    \begin{macrocode}
+        \penalty\@highpenalty
+      \endgroup
+    \fi
+  \end{spacing}
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\l@part}
+% Override \cls{book}'s |\l@part|.
+% (\file{classes.dtx}, L3775)
+%    \begin{macrocode}
+\renewcommand*\l@part[2]{%
+  \if@boldpart
+    \@bold@DUT@majortrue
   \else
-    \def\@svsechd{#4{\hskip #1\relax #5}}%
+    \@bold@DUT@majorfalse
   \fi
-  \@xsect{#3}}
+  \if@dottedpart
+    \@dotted@DUT@majortrue
+  \else
+    \@dotted@DUT@majorfalse
+  \fi
+  \l@DUT@major{#1}{#2}{3em}}
 %    \end{macrocode}
-% Now for |\@sect|.
+% \end{macro}
+%
+% \begin{macro}{\l@chapter}
+% Override \cls{book}'s |\l@chapter|.
+% (\file{classes.dtx}, L3847)
 %    \begin{macrocode}
-\def\@sect#1#2#3#4#5#6[#7]#8{%
-  \ifnum #2>\c@secnumdepth
-    \let\@svsec\@empty
+\renewcommand*\l@chapter[2]{%
+  \if@boldchapter
+    \@bold@DUT@majortrue
   \else
-    \refstepcounter{#1}%
-    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
+    \@bold@DUT@majorfalse
   \fi
-  \@tempskipa #5\relax
-  \ifdim \@tempskipa>\z@
-    \begingroup
-    \begin{spacing}{\@ssp}
-      #6{%
-        \@hangfrom{\hskip #3\relax\@svsec}%
-          \interlinepenalty \@M #8\@@par}%
-    \end{spacing}
-    \endgroup
-    \csname #1mark\endcsname{#7}%
-    \addcontentsline{toc}{#1}{%
-      \ifnum #2>\c@secnumdepth \else
-        \protect\numberline{\csname the#1\endcsname}%
-      \fi
-      #7}%
+  \if@dottedchapter
+    \@dotted@DUT@majortrue
   \else
-    \def\@svsechd{%
-      #6{\hskip #3\relax
-      \@svsec #8}%
-      \csname #1mark\endcsname{#7}%
-      \addcontentsline{toc}{#1}{%
-        \ifnum #2>\c@secnumdepth \else
-          \protect\numberline{\csname the#1\endcsname}%
-        \fi
-        #7}}%
+    \@dotted@DUT@majorfalse
   \fi
-  \@xsect{#5}}
+  \l@DUT@major{#1}{#2}{1.5em}}
 %    \end{macrocode}
+% \end{macro}
+%
 %
-% Override \cls{book}'s |\@part| and |\@spart|, replacing |\Huge| with
-% |\large|.  From |classes.dtx|, |\@part| formats the title of the part,
-% and |\@spart| formats the title of a starred part.
+% \begin{macro}{\l@appendix}
+% Add |\l@appendix|, which is identical to our |\l@chapter| except
+% for setting |\@tempdima| to 8em rather than 1.5em, because the word
+% |Appendix| takes up a bunch of space.
 %    \begin{macrocode}
-\def\@part[#1]#2{%
-    \ifnum \c@secnumdepth >-2\relax
-      \refstepcounter{part}%
-      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
-    \else
-      \addcontentsline{toc}{part}{#1}%
-    \fi
-    \markboth{}{}%
-    {\centering
-     \interlinepenalty \@M
-     \normalfont
-     \ifnum \c@secnumdepth >-2\relax
-       \large\bfseries \partname\nobreakspace\thepart
-       \par
-       \vskip 20\p@
-     \fi
-     \large \bfseries #2\par}%
-    \@endpart}
-\def\@spart#1{%
-    {\centering
-     \interlinepenalty \@M
-     \normalfont
-     \large \bfseries #1\par}%
-    \@endpart}
+\newcommand*\l@appendix[2]{%
+  \if@boldchapter
+    \@bold@DUT@majortrue
+  \else
+    \@bold@DUT@majorfalse
+  \fi
+  \if@dottedchapter
+    \@dotted@DUT@majortrue
+  \else
+    \@dotted@DUT@majorfalse
+  \fi
+  \l@DUT@major{#1}{#2}{8em}}
 %    \end{macrocode}
+% \end{macro}
 %
 %
-% \subsubsection{Adding TOC entries and blank pages}
+% \subsubsection{List of figures}
 %
-% Override \cls{book}'s |\listoftables|, selecting the false branch
-% of the |\if@twocolumn| conditionals, adding a line to the table of
-% contents, and clearing the page.
-% From the Manual 3.6 p10
-% \begin{quote}
-%   The heading |List of Tables| must appear at the top of the first
-%   page.
-%   The heading must be bold, centered, and without punctuation.
-%   List table captions exactly as they appear above the tables in
-%   the text.
-%   Single space each entry, but double-space between entries.
-%   Separate table captions from page numbers with right-justified
-%   tabs and dot leaders.
-%   Do not use periods to separate captions and page numbers.
-%   These pages are counted and numbered in lowercase Roman numerals.
-% \end{quote}
-%    \begin{macrocode}
-\renewcommand\listoftables{%
-  \clearpage
-  \phantomsection
-  \addcontentsline{toc}{chapter}{\listtablename}
-  \chapter*{\listtablename}%
-  \@mkboth{\MakeUppercase\listtablename}%
-          {\MakeUppercase\listtablename}%
-  \@starttoc{lot}%
-}
-%    \end{macrocode}
+% \begin{macro}{\listoffigures}
+% This macro is used to request that \LaTeX\ produces a list of
+% figures. It is very similar to |\tableofcontents|.
 %
-% Override \cls{book}'s |\listoffigures|, selecting the false branch
-% of the |\if@twocolumn| conditionals, adding a line to the table of
-% contents, and clearing the page.
 % From the Manual 3.7 p10
 % \begin{quote}
 %   The heading |List of Figures| must appear at the top of the first
 %   Do not use periods to separate captions and page numbers.
 %   These pages are counted and numbered in lowercase Roman numerals.
 % \end{quote}
+%
+% We drop the \Lopt{twocolumn} code, add a line to the table of
+% contents, and adjust paging.
+% (\file{classes.dtx}, L3981).
 %    \begin{macrocode}
 \renewcommand\listoffigures{%
-  \clearpage
+  \DUT@clearpage
   \phantomsection
-  \addcontentsline{toc}{chapter}{\listfigurename}
+  \AddContentsLine*{toc}{chapter}{}{\listfigurename}
   \chapter*{\listfigurename}%
   \@mkboth{\MakeUppercase\listfigurename}%
           {\MakeUppercase\listfigurename}%
   \@starttoc{lof}%
 }
 %    \end{macrocode}
+% \end{macro}
 %
-% Override |latex.ltx|'s |\bibliography|, adding a line to the table
-% of contents.
-%    \begin{macrocode}
-\def\bibliography#1{%
-  \addcontentsline{toc}{chapter}{\bibname}
-  \if@filesw
-    \immediate\write\@auxout{\string\bibdata{#1}}%
-  \fi
-  \@input@{\jobname.bbl}
-}
-%    \end{macrocode}
 %
-% Add a terminal blank page (when |\if@final| is true)
-% From the Manual 3.16 p13
+% \subsubsection{List of tables}
+%
+% \begin{macro}{\listoftables}
+% This macro is used to request that \LaTeX\ produces a list of
+% tables. It is very similar to |\tableofcontents|.
+%
+% From the Manual 3.6 p10
 % \begin{quote}
-%   Include a blank page (with no page number) at the end of the
-%   thesis or dissertation.  The blank page is neither counted nor
-%   numbered.
+%   The heading |List of Tables| must appear at the top of the first
+%   page.
+%   The heading must be bold, centered, and without punctuation.
+%   List table captions exactly as they appear above the tables in
+%   the text.
+%   Single space each entry, but double-space between entries.
+%   Separate table captions from page numbers with right-justified
+%   tabs and dot leaders.
+%   Do not use periods to separate captions and page numbers.
+%   These pages are counted and numbered in lowercase Roman numerals.
 % \end{quote}
+%
+% We drop the \Lopt{twocolumn} code, add a line to the table of
+% contents, and adjust paging.
+% (\file{classes.dtx}, L4017).
 %    \begin{macrocode}
-\AtEndDocument{\blankpage}
+\renewcommand\listoftables{%
+  \DUT@clearpage
+  \phantomsection
+  \AddContentsLine*{toc}{chapter}{}{\listtablename}
+  \chapter*{\listtablename}%
+  \@mkboth{\MakeUppercase\listtablename}%
+          {\MakeUppercase\listtablename}%
+  \@starttoc{lot}%
+}
 %    \end{macrocode}
+% \end{macro}
 %
 %
-% \subsubsection{Float and display spacing}
+% \subsubsection{Bibliography}
 %
-% From the Manual 2.3 p6, ``Tables and Figures''
-% \begin{quote}
-%   Insert at least 3 single-spaced lines of space above table
-%   captions and figures and below figure captions, tables, and other
-%   graphics.
-% \end{quote}
-% From
-% \href{http://www.eng.cam.ac.uk/help/tpl/textprocessing/squeeze.html}%
-%      {Tim Love's spacing introduction}: \\
-% \begin{tabular}{r p{.8\textwidth}}
-%   |\floatsep| & space left between floats. \\
-%   |\textfloatsep| & space between last top float or first bottom
-%     float and the text. \\
-%   |\intextsep| & space left on top and bottom of an in-text float. \\
-%   |\dbltextfloatsep| & is |\textfloatsep| for 2 column output. \\
-%   |\dblfloatsep| & is |\floatsep| for 2 column output. \\
-%   |\abovecaptionskip| & space above caption \\
-%   |\belowcaptionskip| & space below caption \\
-%   |\abovedisplayskip| & space before maths \\
-%   |\belowdisplayskip| & space after maths \\
-%   |\arraycolsep| & gap between columns of an array \\
-% \end{tabular}
-% However, because of our work in Section \ref{sec:captions},
-% |\belowcaptionskip| \emph{always} gives the distance between the
-% caption and the text, and |\abovecaptionskip| \emph{always} gives
-% the distance between the caption and the float.
+% \begin{environment}{thebibliography}
+% The |thebibliography| environment is a list environment.  To save the
+% use of an extra counter, it should use |enumiv| as the item
+% counter. 
+% Instead of using |\item|, items in the bibliography are produced by
+% the following commands:\\
+%   |\bibitem|\marg{name} : Produces a numbered entry cited as
+%   \meta{name}.\\
+%   |\bibitem|\oarg{label}\marg{name} : Produces an entry labeled by
+%   \meta{Label} and cited by \meta{name}.
+%
+% Override \cls{book}'s version, adding a line to the table of
+% contents.  We split out the section-creation code into
+% |\bib@heading| for \pkg{natbib} compatibility.
+% (\file{classes.dtx}, L4063).
 %    \begin{macrocode}
-\set@lines@length{\floatsep}{\@ssp}
-\set@lines@length{\textfloatsep}{\@tsp}
-\set@lines@length{\intextsep}{\@tsp}
-\set@lines@length{\abovecaptionskip}{\@ssp}
-\set@lines@length{\belowcaptionskip}{\@tsp}
+\renewenvironment{thebibliography}[1]
+     {\bib@heading%
+      \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}}%
 %    \end{macrocode}
-% While we're at it, setup the display spacing.
+% Because it's hard to do line breaks in bibliographies.
 %    \begin{macrocode}
-\set@lines@length{\abovedisplayskip}{\@dsp}
-\set@lines@length{\belowdisplayskip}{\@dsp}
+      \sloppy
 %    \end{macrocode}
-%
-%
-% \subsubsection{Captions}
-% label{sec:captions}
-%
-% These are to get spacing right after table captions and make the
-% spacing around floats symmetrical.  First, set |\if@table| in the
-% |table| environments.
+%    This is setting the normal (non-infinite) value of
+%    |\clubpenalty| for the whole of this environment,
+%    so we must reset its stored value also.  (Why is there a |%| after
+%    the second 4000 below?)
 %    \begin{macrocode}
-\newif\if@table \@tablefalse
-\renewenvironment{table}
-                 {\@tabletrue\@float{table}}
-                 {\end@float\@tablefalse}
-\renewenvironment{table*}
-                 {\@tabletrue\@dblfloat{table}}
-                 {\end@dblfloat\@tablefalse}
+      \clubpenalty4000
+      \@clubpenalty \clubpenalty
+      \widowpenalty4000%
 %    \end{macrocode}
-% Now override \cls{book}'s |\@makecaption|, adding two |\if@table|
-% conditionals, which swap |\abovecaptionskip| and |\belowcaptionskip|
-% for tables (where the caption is above the float body).  With our
-% implementation, |\belowcaptionskip| \emph{always} gives the distance
-% between the caption and the text, and |\abovecaptionskip|
-% \emph{always} gives the distance between the caption and the float
-% body.
+% Cause a `.' (period) not to produce an end-of-sentence space.
+%    \begin{macrocode}
+      \sfcode`\.\@m}
+%    \end{macrocode}
+% Warn if an empty `thebibliography' environment is found.
+%    \begin{macrocode}
+     {\def\@noitemerr
+       {\@latex@warning{Empty `thebibliography' environment}}%
+      \endlist}
+%    \end{macrocode}
+% \end{environment}
 %
-% We also replace the caption lead-in |#1: #2| with
-% |\small{\bfseries#1:} #2|.
+% \begin{macro}{\bib@heading}
+% \pkg{natbib} messes with |thebibliography|.  We setup |\bib@heading|
+% so we will still get our table of contents entry.
 %    \begin{macrocode}
-\newlength\@tempcapskip
-\long\def\@makecaption#1#2{%
-  \if@table
-    \@tempcapskip\abovecaptionskip
-    \abovecaptionskip\belowcaptionskip
-    \belowcaptionskip\@tempcapskip
-  \fi
-  \vskip\abovecaptionskip
-  \sbox\@tempboxa{\small{\bfseries#1:} #2}%
-  \ifdim \wd\@tempboxa >\hsize
-    {\small{\bfseries#1:} #2\par}
-  \else
-    \global \@minipagefalse
-    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
-  \fi
-  \vskip\belowcaptionskip
-  \if@table
-    \@tempcapskip\belowcaptionskip
-    \belowcaptionskip\abovecaptionskip
-    \abovecaptionskip\@tempcapskip
-  \fi
+\newcommand{\bib@heading}{%
+  \phantomsection%
+  \AddContentsLine*{toc}{chapter}{}{\bibname}%
+  \chapter*{\bibname}%
+  \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
 }
 %    \end{macrocode}
+% \end{macro}
 %
-% 
-% \subsubsection{Adjust table of contents}
+% \subsubsection{Words}
 %
-% From the \LaTeX\ base class documentation (|classes.dtx| in
-% \href{http://www.ctan.org/tex-archive/macros/latex/base/}{\pkg{\LaTeX\ base}})
-% \begin{quote}
-%    The command |\contentsline{|\meta{name}|}| expands to
-%    |\l@|\meta{name}.  So, to specify the table of contents, we must
-%    define |\l@chapter|, \ldots
-% \end{quote}
+% Set the official names of the various sections encountered.  Some of
+% these are not defined in \file{classes.dtx} but are close analogs of
+% those that are.
 %
-% Override \cls{book}'s |\l@chapter| for printing TOC entries, adding
-% |spacing| environments to ensure single spacing, only using bold if
-% |\if@boldchapter| is true, handling |\if@dottedchapter|.
-%    \begin{macrocode}
-\renewcommand*\l@chapter[2]{%
-  \begin{spacing}{\@ssp}
-    \ifnum \c@tocdepth >\m@ne
-      \addpenalty{-\@highpenalty}%
-%    \end{macrocode}
-% Don't handle spacing here; use the spacing environment at the end of
-% the macro.
-%    \begin{macrocode}
-%      \vskip 1.0em \@plus\p@
-      \setlength\@tempdima{1.5em}%
-      \begingroup
-        \parindent \z@ \rightskip \@pnumwidth
-        \parfillskip -\@pnumwidth
-        \leavevmode 
-        \if@boldchapter
-          \bfseries
-        \fi
-        \advance\leftskip\@tempdima
-        \hskip -\leftskip
-%    \end{macrocode}
-% Insert |\if@dottedchapter| block into |#1\nobreak\hfil \nobreak...|.
+% \begin{macro}{\dedicationsname}
+% From the Manual 3.3 p9, ``The heading |Dedications| must appear at
+% the top of the page.''
 %    \begin{macrocode}
-        #1\nobreak
-        \if@dottedchapter
-          \leaders\hbox{$\m@th
-            \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}
-          \else\fi
+\newcommand\dedicationsname{Dedications}
 %    \end{macrocode}
-% Insert |\if@dottedchapter| block into |#1\nobreak\hfil \nobreak...|.
+% \end{macro}
+%
+% \begin{macro}{\acknowledgmentsname}
+% From the Manual 3.4 p9, ``The heading |Acknowledgments| must appear
+% at the top of the page.''
 %    \begin{macrocode}
-        \hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
-        \penalty\@highpenalty
+\newcommand\acknowledgmentsname{Acknowledgments}
 %    \end{macrocode}
-% Add a content-page-spacing blank after this entry.
+% \end{macro}
+%
+% \begin{macro}{\contentsname}
+% From the Manual 3.5 p9, ``The heading |Table of Contents| must
+% appear at the top of the page.''  (\file{classes.dtx}, L4331)
 %    \begin{macrocode}
-        \begin{spacing}{\@csp}\par\end{spacing}
-      \endgroup
-    \fi
-  \end{spacing}
-}
+\renewcommand\contentsname{Table of Contents}
 %    \end{macrocode}
+% \end{macro}
 %
-% Add |\l@appendix|, identical to our |\l@chapter|, except for
-% setting |\@tempdima| to 6.5em rather than 1.5em.  TODO: Why?
-% TODO: Consolidate to \l@chapapp[3] calls.
+% \begin{macro}{\listtablename}
+% From the Manual 3.6 p10, ``The heading |List of Tables| must appear
+% at the top of the page.''  (\file{classes.dtx}, L4333)
 %    \begin{macrocode}
-\newcommand*\l@appendix[2]{%
-  \begin{spacing}{\@ssp}
-    \ifnum \c@tocdepth >\m@ne
-      \addpenalty{-\@highpenalty}%
-%      \vskip 1.0em \@plus\p@
-      \setlength\@tempdima{6.5em}%
-      \begingroup
-        \parindent \z@ \rightskip \@pnumwidth
-        \parfillskip -\@pnumwidth
-        \leavevmode 
-        \if@boldchapter
-          \bfseries
-        \fi
-        \advance\leftskip\@tempdima
-        \hskip -\leftskip
-        #1\nobreak
-        \if@dottedchapter
-          \leaders\hbox{$\m@th
-            \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}
-          \else\fi
-        \hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
-        \penalty\@highpenalty
-        \begin{spacing}{\@csp}\par\end{spacing}
-      \endgroup
-    \fi
-  \end{spacing}
-}
+\renewcommand\listtablename{List of Tables}
 %    \end{macrocode}
+% \end{macro}
 %
-% Add |\l@part|, identical to our |\l@chapter|, except for
-% setting |\@tempdima| to 6.5em rather than 1.5em.  TODO: Why?
-% TODO: Consolidate to \l@chapapp[3] calls.
+% \begin{macro}{\listfigurename}
+% From the Manual 3.7 p10, ``The heading |List of Figures| must appear
+% at the top of the page.''  (\file{classes.dtx}, L4332)
 %    \begin{macrocode}
-\renewcommand*\l@part[2]{%
-  \begin{spacing}{\@ssp}
-    \ifnum \c@tocdepth >-2\relax
-      \addpenalty{-\@highpenalty}%
+\renewcommand\listfigurename{List of Figures}
 %    \end{macrocode}
-% Don't handle spacing here; use the spacing environment at the end of
-% the macro.
+% \end{macro}
+%
+% \begin{macro}{\abstractname}
+% From the Manual 3.8 p10, ``The following heading must be centered at
+% the top of the first page: |Abstract|\ldots.''
+% (\file{classes.dtx}, L4367)
 %    \begin{macrocode}
-%    \addvspace{2.25em \@plus\p@}%
-      \setlength\@tempdima{3em}%
-      \begingroup
-        \parindent \z@ \rightskip \@pnumwidth
-        \parfillskip -\@pnumwidth
-        {\leavevmode
+\newcommand\abstractname{Abstract}
 %    \end{macrocode}
-% Replace |\large \bfseries| with |\if@boldpart...|, so the parts are
-% the same size as the other entries, and bolding obeys |if@boldpart|.
+% \end{macro}
+%
+% \begin{macro}{\bibname}
+% From the Manual 3.13 p12, ``The heading |Bibliography| (or
+% |List of References|) must appear at the top of first page.''
+% (\file{classes.dtx}, L4344)
 %    \begin{macrocode}
-         \if@boldpart
-           \bfseries
-         \fi
-         #1
+\renewcommand\bibname{Bibliography}
 %    \end{macrocode}
-% Insert |\if@dottedpart| between |#1| and |\hfil|.
+% \end{macro}
+%
+% \begin{macro}{\appendixname}
+% From the Manual 3.14 p12, ``Number the appendicies consecutively
+% either alphabetically or numerically (|Appendix A|, |Appendix B|\ldots
+% or |Appendix 1|, |Appendix 2|\ldots).''
+% (\file{classes.dtx}, L4366)
 %    \begin{macrocode}
-         \if@dottedpart
-           \leaders\hbox{$\m@th
-             \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}
-         \fi
-         \hfil \hb@xt@\@pnumwidth{\hss #2}}\par
-         \nobreak
-           \global\@nobreaktrue
-           \everypar{\global\@nobreakfalse\everypar{}}%
+\renewcommand\appendixname{Appendix}
 %    \end{macrocode}
-% Add a content-page-spacing blank after this entry.
+% \end{macro}
+%
+% \begin{macro}{\vitaname}
+% From the Manual 3.15 p13, ``The heading |Vita| must appear at the
+% top of the page.''
 %    \begin{macrocode}
-           \begin{spacing}{\@csp}\par\end{spacing}
-      \endgroup
-    \fi
-  \end{spacing}
-}
+\newcommand\vitaname{Vita}
 %    \end{macrocode}
+% \end{macro}
+%
 %
-% Override |latex.ltx|'s |\dottedtocline|, adding some |spacing|
-% environments.  TODO: reasoning.
+% \subsection{Remaining details}
+%
+%
+% \subsubsection{Terminal blank page}
+%
+% Add a terminal blank page (when |\if@final| is true)
+% From the Manual 3.16 p13
+% \begin{quote}
+%   Include a blank page (with no page number) at the end of the
+%   thesis or dissertation.  The blank page is neither counted nor
+%   numbered.
+% \end{quote}
 %    \begin{macrocode}
-\def\@dottedtocline#1#2#3#4#5{%
-  \begin{spacing}{\@ssp}
-  \ifnum #1>\c@tocdepth \else
-    \vskip \z@ \@plus.2\p@
-    {\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
-     \parindent #2\relax\@afterindenttrue
-     \interlinepenalty\@M
-     \leavevmode
-     \@tempdima #3\relax
-     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
-     {#4}\nobreak
-     \leaders\hbox{$\m@th
-        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
-        mu$}\hfill
-     \nobreak
-     \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
-     \par\begin{spacing}{\@csp}\par\end{spacing}}%
-  \fi
-  \end{spacing}
-}
+\AtEndDocument{\blankpage}
 %    \end{macrocode}
 %
-% Override \cls{book}'s (or \pkg{hyperref}'s) |\appendix|, adding
-% |\@appendixtrue|.  This gets |\if@appendix| working in our
-% |\chapter| definition below.
+%
 %    \begin{macrocode}
-\let\DUT@appendix\appendix
-\renewcommand\appendix{%
-  \@appendixtrue%
-  \DUT@appendix
-}
+%</class>
 %    \end{macrocode}
 %
-% Override \cls{book}'s |\chapter|, selecting the false branch of the
-% |\if@twocolumn| conditional and adding an |\if@appendix|
-% conditional.  After |\appendix| (when |\if@mainmatter| and
-% |\if@appendix| are both true), we generate table of content entries
-% such as \emph{Appendix A: Chapter Title} rather than the standard
-% \emph{Chapter Title}.  |\thechapter| (defined in \cls{book}) is the
-% appendix letter (e.g.\ |A|).  |\@chapapp{}| (also defined in
-% \cls{book}) Was redefined in |\appendix| (above) as |\appendixname|.
-% Before |\appendix|, we reproduce the \cls{book} behavior.
-%    \begin{macrocode}
-\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
-                       \if@mainmatter
-                         \refstepcounter{chapter}%
-                         \typeout{\@chapapp\space\thechapter.}%
-                         \if@appendix
-                           \addcontentsline{toc}{appendix}%
-                                     {\protect\numberline{\@chapapp{} \thechapter:}#1}%
-                         \else
-                           \addcontentsline{toc}{chapter}%
-                                     {\protect\numberline{\thechapter}#1}%
-                         \fi
-                       \else
-                         \addcontentsline{toc}{chapter}{#1}%
-                       \fi
-                    \else
-                      \addcontentsline{toc}{chapter}{#1}%
-                    \fi
-                    \chaptermark{#1}%
-                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
-                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
-                    \@makechapterhead{#2}%
-                    \@afterheading}
-%    \end{macrocode}
 %
+% \subsection{Caveats and bugs}
 %
-% \iffalse meta-comment
-%</class>
-% \fi
 %
+% \subsubsection{\pkg{hyperref} and uppercase}
 %
-% \section{Templates}
+% In order to comply with the Manual's specifications,
+% part and chapter entries to the table of contents need
+% to be uppercased, which we do via |\AddContentsLine|.
+% This generates some whining from \pkg{hyperref}
+% \begin{example}
+%   Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding),
+%   (hyperref)                removing `\uppercase' on input line 72.
+% \end{example}
+% This is because |\uppercase| is parsed in \TeX's stomach, but
+% \pkg{hyperref} deals with code in \TeX's mouth, so \pkg{hyperref} is
+% drops the token and complains.  Which is fine, since the titles
+% don't actually need to be uppercased in the bookmark, but the
+% error messages are still produced.  If anyone knows of a good way
+% to either fix the problem or silence these particular error messages,
+% please let me know.  Otherwise, just ignore the errors.
 %
-% \subsection{Simple}
 %
-% \subsubsection{Main}
+% \section{Examples}
 %
-% \iffalse meta-comment
-%<*template-main>
-% \fi
-% \begin{quote} \hrule \begin{verbatim}
-%% See drexel-thesis.pdf for details.
+%
+% \subsubsection{Template}
+%
+%    \begin{macrocode}
+%<*template>
+% See drexel-thesis.pdf for details.
 \documentclass{drexel-thesis}
 
 %% Enter the appropriate information here
-\author{Johny Henry} % Fullname
-\title{Inadequacies of Steam-Driven Boring Machines}  % Title Of Thesis
-\defmonth{July}  % Name of the month of you defense
-\defyear{1872}   % Year you are defending
-\degree{Doctor of Philosophy} % Should be fine
-\advisor{C \& O Railroad, Ph.D.}   % Put Advisor's full name, degree
+\author{}    % Fullname
+\title{}     % Title Of Thesis
+\defmonth{}  % Name of the month of you defense
+\defyear{}   % Year you are defending
+\degree{}    % Your target degree, spelled out
+\advisor{}   % Advisor's full name, degree
+\copyrighttext{} % If not "All Rights Reserved."
 
-\usepackage{graphicx}   % to include images
-
-%% \blabla related code for producing example output
-\usepackage{forloop}
-%% http://www.ctan.org/tex-archive/macros/latex/contrib/forloop/
-\newcounter{blabla_i}
-\newcounter{blabla_j}
-\newcommand{\blabla}[2]{
-  \forloop{blabla_i}{0}{\value{blabla_i} < #1}{
-    Bla
-    \forloop{blabla_j}{0}{\value{blabla_j} < #2}{ bla }
-    bla.\par
-  }
-}
-%% end \blabla related code
+%% unsrt style give references in order of citation
+\bibliographystyle{unsrt}
 
 \begin{document}
 \begin{preamble}
 
 \begin{dedications} % OPTIONAL
-Type dedications here
+%% Type dedications here
 \end{dedications}
 
 \begin{acknowledgments} % OPTIONAL
-Type acknowledgments here
+%% Type acknowledgments here
 \end{acknowledgments}
 
 \tableofcontents
-%% Include these following commands only if you have tables or figures.
-%% Tables should come before figures.
-\listoftables
-\listoffigures
+\listoftables  % If you have tables
+\listoffigures % If you have figures
 
 \begin{abstract}
-Type abstract here
+%% Type abstract here
 \end{abstract}
 \end{preamble}
 
 \begin{thesis}
 %% Use include statements to include your main thesis code
 %% from seperate files.
-\include{part1}
+%%\include{part1}
+%%...
 \end{thesis}
 
-%% unsrt style give references in order of citation
-\bibliographystyle{unsrt}
-\phantomsection
-\addcontentsline{toc}{chapter}{\bibname}
-\begin{thebibliography}{9}
-% widest label (above "9"), when printed, as wide as widest entry label.
-\bibitem{lamport94}
-  Leslie Lamport,
-  \emph{\LaTeX: A Document Preparation System}.
-  Addison Wesley, Massachusetts,
-  2nd Edition,
-  1994.
-%...
-\end{thebibliography}
+\bibliography{references} % Include references.bib BibTeX
 
-\appendix
+\appendix % If you have appendices
 %% include files with your appendicies (if any) here
-\include{appendixA}
+%%\include{appendixA}
+%%...
 
-\begin{vita} % Ph.D. only.  See Thesis Manual for details.
-Vita text.
+\begin{vita} % Ph.D. only.
+%%Vita text.
 \end{vita}
 
 \end{document}
-% \end{verbatim} \hrule \end{quote}
-% \iffalse meta-comment
-%</template-main>
-% \fi
-%
-% \subsubsection{Part}
-%
-% \iffalse meta-comment
-%<*template-part>
-% \fi
-% \begin{quote} \hrule \begin{verbatim}
-\part{A Part Heading}
-\chapter{A Chapter Heading}
-\section{A Section Heading}
-The following sectioning commands are available:
-\begin{quote}
- part \\
- chapter \\
- section \\
- subsection \\ 
- subsubsection \\ 
- paragraph \\ 
- subparagraph 
-\end{quote}
-\begin{table}
-  \caption{A table float}
-  \begin{center}
-  \begin{tabular}{r@{.}l r@{.}l r@{.}l}
-    \multicolumn{2}{c}{Time (s)} &
-      \multicolumn{2}{c}{John Henry (m)} &
-      \multicolumn{2}{c}{Steam drill (m)} \\
-    0&0 & 0&0 & 0&0 \\
-    10&0 & 4&3 & 3&75 \\
-    30&0 & 11&9 & 10&1 \\
-    \ldots
-  \end{tabular}
-  \end{center}
-\end{table}
-\blabla{5}{20}
-\begin{figure}
-  \begin{center}
-    \includegraphics[width=0.4\textwidth]{drexel-logo}
-  \end{center}
-  \caption{A figure float}
-\end{figure}
-\blabla{10}{20}
-% \end{verbatim} \hrule \end{quote}
-% \iffalse meta-comment
-%</template-part>
-% \fi
-%
-% Note the strange |r@{.}l| notation in the |\tabular| column
-% definition.  This allows for numbers aligned at the decimal point
-% (see \href{http://www.stat.unipg.it/tex-man/ltx-68.html}{here}).
-%
-% |\multicolumn{num_cols}{alignment}{contents}| allows the headings
-% to span the pre- and post-decimal columns.
-%
-%
-% \subsubsection{Appendix}
-%
-% \iffalse meta-comment
-%<*template-appendix>
-% \fi
-% \begin{quote} \hrule \begin{verbatim}
-\chapter{Some Appendix Heading}
-\blabla{10}{20}
-\chapter{Another Appendix Heading}
-\blabla{10}{20}
-% \end{verbatim} \hrule \end{quote}
-% \iffalse meta-comment
-%</template-appendix>
-% \fi
+%</template>
+%    \end{macrocode}
 %
 %
-% \subsection{\BibTeX/\pkg{natbib}}
-% \label{sec:natbib-example}
+% \subsection{A better example}
+% \label{sec:better-example}
 %
 % \subsubsection{Main}
 %
-% \iffalse meta-comment
-%<*template-bibtex-main>
-% \fi
-% \begin{quote} \hrule \begin{verbatim}
+%     \begin{macrocode}
+%<*example|example-draft>
 %% See drexel-thesis.pdf for details.
-\documentclass[draft]{drexel-thesis}
+%<example>\documentclass{drexel-thesis}
+%<example-draft>\documentclass[draft]{drexel-thesis}
 
 %% Enter the appropriate information here
-\author{Johny Henry} % Fullname
-\title{Inadequacies of Steam-Driven Boring Machines}  % Title Of Thesis
-\defmonth{July}  % Name of the month of you defense
-\defyear{1872}   % Year you are defending
-\degree{Doctor of Philosophy} % Should be fine
-\advisor{C \& O Railroad, Ph.D.}   % Put Advisor's full name, degree
+\author{Johny Henry}
+\title{Inadequacies of Steam-Driven Boring Machines}
+\defmonth{July}
+\defyear{1872}
+\degree{Doctor of Philosophy}
+\advisor{Collis Potter Huntington, R.R.D.}
+\copyrighttext{\copyrighttextCC}
 
 \usepackage[super,sort&compress]{natbib} % fancy citation extensions
-%% super selects citations in superscript mode.
-%% sort&compress automatically sorts and compresses compound citations:
-%%   \pcite{a,b,...}
 \bibliographystyle{plainnat}
 
-%% \blabla related code for producing example output
-\usepackage{forloop}
-%% http://www.ctan.org/tex-archive/macros/latex/contrib/forloop/
-\newcounter{blabla_i}
-\newcounter{blabla_j}
-\newcommand{\blabla}[2]{
-  \forloop{blabla_i}{0}{\value{blabla_i} < #1}{
-    Bla
-    \forloop{blabla_j}{0}{\value{blabla_j} < #2}{ bla }
-    bla.\par
-  }
-}
-%% end \blabla related code
+\usepackage{fancyvrb} % nicer verbatim handling
+\DefineShortVerb{\|}  % \verb+TEXT+  ->  |TEXT|
+
+\usepackage{blabla} % \blabla macro for producing dummy output
 
 \begin{document}
 \begin{preamble}
 
-\begin{dedications} % OPTIONAL
-Type dedications here
+\begin{dedications}
+\blabla{10}{20}
 \end{dedications}
 
-\begin{acknowledgments} % OPTIONAL
-Type acknowledgments here
+\begin{acknowledgments}
+\blabla{10}{20}
 \end{acknowledgments}
 
 \tableofcontents
-%% Include these following commands only if you have tables or figures.
-%% Tables should come before figures.
 \listoftables
 \listoffigures
 
 \begin{abstract}
-Type abstract here
+\blabla{10}{20}
 \end{abstract}
 \end{preamble}
 
 \begin{thesis}
-%% Use include statements to include your main thesis code
-%% from seperate files.
-\include{bibpart1}
+\include{example-1}
 \end{thesis}
 
-\bibliography{references}
+\bibliography{example-ref}
 
 \appendix
-%% include files with your appendicies (if any) here
-\include{appendixA}
+\include{example-a}
 
-\begin{vita} % Ph.D. only.  See Thesis Manual for details.
-Vita text.
+\begin{vita}
+\blabla{10}{20}
 \end{vita}
 
 \end{document}
-% \end{verbatim} \hrule \end{quote}
-% \iffalse meta-comment
-%</template-bibtex-main>
-% \fi
+%</example|example-draft>
+%    \end{macrocode}
 %
-% \subsubsection{Part}
 %
-% You can cite your references with \pkg{natbib}'s |\citet| and
-% |\citep| macros.  See
-% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/}{the \pkg{natbib} manual}
-% for details.
+% \subsubsection{Part}
 %
-% \iffalse meta-comment
-%<*template-bibtex-part>
-% \fi
-% \begin{quote} \hrule \begin{verbatim}
+%     \begin{macrocode}
+%<*example-part>
 \part{A Part Heading}
 \chapter{A Chapter Heading}
 \section{A Section Heading}
+The following sectioning commands are available:
+\begin{quote}
+ part \\
+ chapter \\
+ section \\
+ subsection \\ 
+ subsubsection \\ 
+ paragraph \\ 
+ subparagraph 
+\end{quote}
+
+\subsection{natbib}
+You can cite your references with |natbib|'s |\citet| and |\citep|
+macros.  See
+\href{http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/}
+{the natbib manual} for details.
+
 Here we have a text citation \citet{rief97} followed by a
 parenthetical citation\citep{rief97}.
+
+\subsubsection{Tables and Figures}
+\blabla{2}{20}
+\begin{table}
+  \caption{A table float}
+  \begin{center}
+  \begin{tabular}{r@{.}l r@{.}l r@{.}l}
+    \multicolumn{2}{c}{Time (s)} &
+      \multicolumn{2}{c}{John Henry (m)} &
+      \multicolumn{2}{c}{Steam drill (m)} \\
+    0&0 & 0&0 & 0&0 \\
+    10&0 & 4&3 & 3&75 \\
+    30&0 & 11&9 & 10&1 \\
+    \ldots
+  \end{tabular}
+%% Note the strange |r@{.}l| notation in the |\tabular| column
+%% definition.  This allows for numbers aligned at the decimal point
+%% (see \href{http://www.stat.unipg.it/tex-man/ltx-68.html}{here}).
+%%
+%% |\multicolumn{num_cols}{alignment}{contents}| allows the headings
+%% to span the pre- and post-decimal columns.
+  \end{center}
+\end{table}
+\blabla{5}{20}
+\begin{figure}
+  \begin{center}
+    \includegraphics[width=0.4\textwidth]{drexel-logo}
+  \end{center}
+  \caption{A figure float}
+\end{figure}
 \blabla{10}{20}
-% \end{verbatim} \hrule \end{quote}
-% \iffalse meta-comment
-%</template-bibtex-part>
-% \fi
+
+\part{Another Part}
+\chapter{Another Chapter}
+\blabla{30}{20}
+\chapter{Yet another Chapter}
+\blabla{30}{20}
+%</example-part>
+%    \end{macrocode}
 %
-% \subsubsection{Bib}
 %
-% What goes into the \BibTeX\ file |references.bib|?
+% \subsubsection{\BibTeX}
+%
+% What goes into the \BibTeX\ file |example-ref.bib|?
 % For more information, check out this 
 % \href{http://cmtw.harvard.edu/Documentation/TeX/Bibtex/Example.html}{basic tutorial}.
 % If you want to get deeper, take a look at
@@ -2101,12 +2794,10 @@ parenthetical citation\citep{rief97}.
 %
 % Here is an example \BibTeX\ file to get you started.  We define
 % strings for the publishers, journals, and authors to avoid
-% duplication and minimize the risk of typos, etc.
+% duplication, minimize the risk of typos, etc.
 %
-% \iffalse meta-comment
-%<*template-bibtex-refs>
-% \fi
-% \begin{quote} \hrule \begin{verbatim}
+%    \begin{macrocode}
+%<*example-bibtex-refs>
 %% Publishers
 @String{APS = "American Physical Society"}
 
@@ -2141,10 +2832,44 @@ parenthetical citation\citep{rief97}.
            of its globular-chain structure.",
 }
 %% ...
-% \end{verbatim} \hrule \end{quote}
-% \iffalse meta-comment
-%</template-bibtex-refs>
-% \fi
+%</example-bibtex-refs>
+%    \end{macrocode}
+%
+%
+% \subsubsection{Appendix}
+%
+%    \begin{macrocode}
+%<*example-appendix>
+\chapter{Some Appendix Heading}
+\blabla{10}{20}
+\chapter{Another Appendix Heading}
+\blabla{10}{20}
+%</example-appendix>
+%    \end{macrocode}
+%
+%
+% \subsubsection{\pkg{blabla}}
+%
+% Define the \pkg{blabla} package for generating dummy text.  This
+% will make it easier to generate reasonable exampes.
+%    \begin{macrocode}
+%<*blabla>
+\ProvidesPackage{blabla} [2010/01/11 1.0 Dummy text generation]
+\RequirePackage{forloop}[2006/09/18]
+%% http://www.ctan.org/tex-archive/macros/latex/contrib/forloop/
+
+\newcounter{blabla@i}
+\newcounter{blabla@j}
+\newcommand{\blabla}[2]{
+  \forloop{blabla@i}{0}{\value{blabla@i} < #1}{
+    Bla
+    \forloop{blabla@j}{0}{\value{blabla@j} < #2}{ bla }
+    bla.\par
+  }
+}
+%</blabla>
+%    \end{macrocode}
+%
 %
 % \Finale
 \endinput