Repositioned hyperref inclusion and fixed \change backslash escaping
[drexel-thesis.git] / drexel-thesis.dtx
index ea928ece2afa596b15f1ceea3b755cd5759bf568..46676d8672be65eda9c7576006d1f0e04b94bbc5 100644 (file)
@@ -1,11 +1,22 @@
-% \def\fileversion{0.3}
-% \def\filedate{2010/01/09}
+% \def\fileversion{0.4}
+% \def\filedate{2010/02/23}
 % \iffalse meta-comment
-%<class>\def\fileversion{0.3}
-%<class>\def\filedate{2010/01/09}
-%
-% Copyright (C) 2010 W. Trevor King, Daniel J. Cross, T. Tsankov, and
-%    R. Rojas.
+%<class>\def\fileversion{0.4}
+%<class>\def\filedate{2010/02/23}
+%
+% Copyright (C) 2010  C.Y. Ip
+%                     Christopher D. Cera
+%                     Christopher S. Dahn
+%                     Daniel J. Cross
+%                     David T. McWherter
+%                     Evan Sultanik
+%                     Jeff Arahamson
+%                     Mitchell Peabody
+%                     R. Rojas, E
+%                     Robert Bernecky
+%                     T. Tsankov
+%                     Vincent A. Cicirello
+%                     W. Trevor King
 % -------------------------------------------------------
 % 
 % This file may be distributed and/or modified under the
@@ -18,7 +29,8 @@
 % and version 1.3 or later is part of all distributions of LaTeX 
 % version 2003/12/01 or later.
 %
-% Based on Scott Pakin's dtxtut/cskeleton.dtx
+% Docstrip formatting initially based on Scott Pakin's
+% dtxtut/cskeleton.dtx
 %   http://www.ctan.org/tex-archive/info/dtxtut/
 %
 % \fi
 % \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.3}{2010/01/11}{W.~Trevor King merged drexelthesis.cls
+% \changes{0.3}{2010/01/13}{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 \LaTeXe\ Class.  Also
 %   greatly improved the documentation by incorperating bits of
 %   the base/*.dtx files.}
+% \changes{0.4}{2010/02/23}{W.~Trevor King repositioned hyperref
+%   inclusion for proper hyperref overriding.  The previous
+%   implementation couldn't handle $\backslash$label for
+%   $\backslash$paragraph and some other section levels.  The page
+%   number for the reference was correct, but the link went to the
+%   label's parent chapter.}
 %
 % \MakeShortVerb{\|}
 % \newcommand{\pkg}[1]{\textsf{#1}}
 %   \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. \\
+%   \Lopt{mydraftwatermark} & It's good to have a timestamp. \\
 % \end{tabular}
 %
+% \DescribeOption{subfig}
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/subfig/}{\pkg{subfig}}
+% makes it easy to include and caption multi-part figures.  However,
+% getting \pkg{subfig} to cooperate with \pkg{floatrow} and
+% \pkg{tocloft} can be tricky.  If you want to use \pkg{subfig}, just
+% pass the \Lopt{subfig} option to \cls{drexel-thesis}, and all the
+% pesky details will be taken care of.  See Section
+% \ref{sec:better-example} for an example.
+%
 % \DescribeOption{finalspace}
 % Loosen spacing.
 %
 % options set all of the types.  For example, \Lopt{boldtoc} is
 % equivalent to \Lopt{boldchapter,boldpart}.
 %
+% \DescribeOption{indenttoc}
+% The example table of contents in the Manual p17 does not indent
+% section entries, etc., so neither does \cls{drexel-thesis}.  If you
+% \emph{do} want pretty, indented TOCs, like the \LaTeX\ defaults pass
+% \Lopt{indenttoc} to \cls{drexel-thesis}.
+%
 % \DescribeOption{draftwatermark}
 % \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.
+% correcting.  Requires the \pkg{draftmark} package.
+%
+% \DescribeOption{mydraftwatermark}
+% \Lopt{mydraftwatermark} is similar to \Lopt{draftwatermark} but
+% depends on the possibly more common \pkg{xcolor}, \pkg{eso-pic},
+% and \pkg{graphicx}.
 %
 % \DescribeOption{indentfirst}
 % \Lopt{indentfirst} indents the first paragraph after sections etc.
 % See the Manual 3.2 p9.
 %
 % \begin{command}
-%   `\cs{copyrighttextCC}'
+%   `\cs{copyrighttextCCBYSA}'
 % \end{command}
 % There are a number of predefined copyright messages for ease of use \\
 % \begin{tabular}{l l}
-%   |\copyrighttextCC| & Creative Commons copyright \\
+%   |\copyrighttextCCBYSA| &
+%     Creative Commons Attribution-ShareAlike License Version 3.0.\\
 % \end{tabular}
 %
 % \begin{command}
 %      \caption{Some caption text}
 %   \end{float}
 % \end{example}
-% For more useful float information, see the
+% For more useful float information, see the examples in Section
+% \ref{sec:better-example-part} and the
 % \href{http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions}
 %   {\LaTeX\ wikibook page}.
-% 
+%
 %
 % \subsubsection{Citations}
 %
 %
 % \subsubsection{References}
 %
+% Easier cross referencing with
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/cleveref/}{\pkg{cleveref}}.
-% Is a wonderful tool for easy, consistent crosslinking.  The manual is also very good.
+% Is a wonderful tool for easy, consistent crosslinking via |\cref|,
+% |\Cref|, etc..  The manual is also very good.
+% Note that if you use |\part|s in your document, you need to tell
+% \pkg{cleveref} how to deal with them:
+% \begin{example}
+%   \usepackage{cleveref}
+%   \crefname{part}{part}{parts}
+% \end{example}
 %
 %
 % \subsubsection{Hyperlinks}
 % set options overriding these defaults.
 %
 %
+% \subsubsection{Developing large \LaTeX\ documents}
+%
+% A thesis may take a while to compile, especially if it contains
+% lots of images, etc..  One way to save time, is to use |\includeonly|
+% when including chapter \file{*.tex} files (see
+% \href{http://en.wikibooks.org/wiki/TeX/includeonly}{the \TeX\ Wikibook}).
+% Usage would be something like
+% \begin{example}
+% \documentclass{drexel-thesis}
+% ...
+% \includeonly{chapter2.tex,chapter3.tex}
+% \begin{document}
+% ...
+% \begin{thesis}
+% \include{chapter1.tex}
+% \include{chapter2.tex}
+% \include{chapter3.tex}
+% \include{chapter4.tex}
+% \end{thesis}
+% ...
+% \end{document}
+% \end{example}
+% which would only compile chapters two and three.  Don't confuse the
+% similar commands |\include| and |\input|.  The more fundamental
+% |\input| just inserts the file contents at that point, while
+% |\include|
+% \begin{itemize}
+%   \item may only be used after |\begin{document}|
+%   \item acts like |\clearpage \input{} \clearpage|
+%   \item will not crash on nonexistent files
+% \end{itemize}
+%
+%
 % \StopEventually{\pagebreak\PrintChanges}
 %
 %
 % Define some booleans to store option states
 %    \begin{macrocode}
 \newif\if@mainmatter \@mainmattertrue
+\newif\if@DUT@subfigopt
 \newif\if@dottedchapter 
 \newif\if@boldchapter
 \newif\if@boldpart
 \newif\if@dottedpart
+\newif\if@indenttoc
 \newif\if@draftwatermark
+\newif\if@mydraftwatermark
 \newif\if@indentfirst
 \newif\if@final \@finalfalse
 %    \end{macrocode}
 %
+% \begin{option}{subfig}
+% Set \Lopt{subfig} flag
+%    \begin{macrocode}
+\DeclareOptionX{subfig}{\@DUT@subfigopttrue}
+%    \end{macrocode}
+% \end{option}
+%
 % \begin{option}{finalspace}
 %    \begin{macrocode}
 \DeclareOptionX{finalspace}{
 % \begin{option}{dottedchapter}
 %    \begin{macrocode}
 \DeclareOptionX{dottedchapter}{\@dottedchaptertrue}
-%    \end{macrocode}
+%    \end{macrocode}1
 % \end{option}
 % \begin{option}{boldpart}
 %    \begin{macrocode}
 %    \end{macrocode}
 % \end{option}
 %
+% \begin{option}{indenttoc}
+% Set \Lopt{indenttoc} flag
+%    \begin{macrocode}
+\DeclareOptionX{indenttoc}{\@indenttoctrue}
+%    \end{macrocode}
+% \end{option}
+%
 % \begin{option}{draftwatermark}
 % Set \Lopt{draftwatermark} flag
 %    \begin{macrocode}
-\DeclareOptionX{draftwatermark}{\@draftwatermarktrue}
+\DeclareOptionX{draftwatermark}{%
+  \@draftwatermarktrue
+  \@mydraftwatermarkfalse}
+%    \end{macrocode}
+% \end{option}
+%
+% \begin{option}{mydraftwatermark}
+% Set \Lopt{mydraftwatermark} flag
+%    \begin{macrocode}
+\DeclareOptionX{mydraftwatermark}{%
+  \@mydraftwatermarktrue
+  \@draftwatermarkfalse}
 %    \end{macrocode}
 % \end{option}
 %
   \setkeys{drexel-thesis.cls}{twoside}
   \setkeys{drexel-thesis.cls}{draftspace}
   \setkeys{drexel-thesis.cls}{dottedtoc}
-  \setkeys{drexel-thesis.cls}{draftwatermark}
+  \setkeys{drexel-thesis.cls}{mydraftwatermark}
 }
 %    \end{macrocode}
 % \end{option}
 \fi
 %    \end{macrocode}
 %
+% Here is Evan's alternative implementation This will not look right
+% as a DVI, but it'll look fine once rendered to either a PS or PDF.
+%    \begin{macrocode}
+\if@mydraftwatermark
+%    \end{macrocode}
+% Use \pkg{eso-pic} for |\AddToShipoutPicture|.
+%    \begin{macrocode}
+  \RequirePackage{eso-pic}
+%    \end{macrocode}
+% Use \pkg{xcolor} for |\definecolor|.
+%    \begin{macrocode}
+  \RequirePackage{xcolor}
+  \definecolor{watermark}{rgb}{0.9,0.9,0.9}
+%    \end{macrocode}
+% Set the font explicitly to avoid being effected by the last text on
+% the page having some strange font.  |\sffamily| sets a sans serif
+% font.
+%    \begin{macrocode}
+  \newcommand{\watermarkfont}{%
+    \color{watermark}}%\fontfamily{phv}\selectfont\sffamily}
+  \newcommand{\watermark}{%
+    \rule{4.25in}{0pt}\raisebox{5.5in}{%
+      \makebox[0pt]{%
+%    \end{macrocode}
+% |\rotatebox| and |\resizebox| from \pkg{graphicx}.
+%    \begin{macrocode}
+       \rotatebox[origin=c]{45}{%
+          \resizebox{!}{1.5in}{%
+            {\watermarkfont DRAFT}%
+    }}}}
+    \raisebox{4.2in}{%
+      \makebox[0pt]{%
+       \rotatebox[origin=c]{45}{%
+          \resizebox{!}{.6in}{%
+            {\watermarkfont \qquad\today}%
+    }}}}}
+  \AddToShipoutPicture{\watermark{}}
+\fi
+%    \end{macrocode}
+%
 %
 % \subsubsection{\pkg{indentfirst}}
 %
 % Typeset the table of contents, etc., with
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/tocloft/}{\pkg{tocloft}}.
 %    \begin{macrocode}
-\RequirePackage{tocloft}
+\if@DUT@subfigopt
+  \RequirePackage[subfigure]{tocloft}
+\else
+  \RequirePackage{tocloft}
+\fi
 %    \end{macrocode}
+% The \Lopt{subfigure} option sets up \pkg{tocloft} for
+% \pkg{subfig}/\pkg{subfigure} compatibility. See the
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/tocloft/tocloft.pdf}{%
+%   \pkg{tocloft} manual, Section 2.1}
+% for details.
+%
 % The configuration of \pkg{tocloft} takes place in Sections
 % \ref{sec:implement-toc}, \ref{sec:implement-lof}, and
 % \ref{sec:implement-lot}.
 \floatsetup{captionskip=10pt}
 \floatsetup[table]{captionskip=10pt}
 %    \end{macrocode}
+% Use \pkg{fr-subfig} for \pkg{floatrow}/\pkg{subfig} compatibility.
+% See the \pkg{floatrow} documentation (Sec.~7.1, ``The \pkg{subfig}
+% package'') and \pkg{subfig} documentation (Sec.~4.3,
+% ``\pkg{FloatRow} Package'') for details.
+%    \begin{macrocode}
+\if@DUT@subfigopt
+  \RequirePackage{fr-subfig}
+\fi
+%    \end{macrocode}
 % We set up the three-line surrounding spaces in Section
 % \ref{sec:implement-floats}.
 %
 % won't need to.
 %
 %
+% \subsubsection{\pkg{subfig}}
+% \label{sec:subfig}
+%
+% Allow multi-part figures with
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/subfig/}{\pkg{subfig}}.
+%    \begin{macrocode}
+\if@DUT@subfigopt
+  \RequirePackage{subfig}
+\fi
+%    \end{macrocode}
+%
+%
 % \subsubsection{\pkg{fancyhdr}}
+% \label{sec:fancyhdr}
 %
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/}{\pkg{fancyhdr}}
 % for correct page numbering and fancy headers.
 %    \begin{macrocode}
 \pagestyle{fancy}
 \fancyhf{}
+%    \end{macrocode}
+% Turn off the header rule by setting its width to $0$.
+%    \begin{macrocode}
 \renewcommand{\headrulewidth}{0pt}
 %    \end{macrocode}
 % 0.4 pt is \pkg{fancyhdr}'s default |\headrulewidth|, so we'll
 % We put the lower level mark to the outside because it changes more
 % often.  Page numbers also go on the outside.
 %    \begin{macrocode}
-\fancyfoot[RE,LO]{\slshape\leftmark}
-\fancyfoot[LE,RO]{\slshape\rightmark}
+\fancyfoot[RE,LO]{\scshape\leftmark}
+\fancyfoot[LE,RO]{\scshape\rightmark}
 \fancyhead[LE,RO]{\thepage}
 %    \end{macrocode}
 % Override the |plain| format (for part pages, etc.).
 }
 %    \end{macrocode}
 %
+% Note that the Chapter / Section footer is not required.  You can
+% remove the footer text and rule entirely with.
+% \begin{example}
+%   \renewcommand{\footrulewidth}{0pt}
+%   \fancyfoot[RE,LO]{}
+%   \fancyfoot[LE,RO]{}
+% \end{example}
+%
 %
 % \subsubsection{\pkg{ifpdf}}
 %
 %    \end{macrocode}
 % 
 % \subsubsection{\pkg{hyperref}}
+% \label{sec: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[final]{hyperref}
-%    \end{macrocode}
-% Nobody likes the default colored boxes.  Color the text itself.
-%    \begin{macrocode}
-\hypersetup{colorlinks}
-%    \end{macrocode}
-% If we're writing a PDF, we set the |pdfauthor|, etc.\ arguments in
-% |\author|, etc.\ to avoid using |\AtBeginDocument| or some such.
+% thesis without it.  We actually include this later
+% (Section~\ref{sec:hyperref-inclusion}), because \pkg{hyperref}
+% sticks its fingers into \emph{everything} and we want it to use our
+% versions of some macros (e.g. |\@sect|) but not others
+% (e.g. |thebibliography|).
 %
 %
 % \subsection{\LaTeX\ overrides and extensions}
 % |\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|.
+% We extend |\author| to set \pkg{hyperref}'s |pdfauthor| if we're
+% writing a PDF to avoid using |\AtBeginDocument| or some such.
 % (\file{ltsect.dtx}, L129).
 %    \begin{macrocode}
 \let\DUT@author\author
 % \begin{macro}{\DUT@baselineskip}
 % Since we'll be messing with the spacing, save the single-spaced
 % baseline.
+%   \changes{0.3}{2010/01/13}{Use $\backslash$setlength to store the
+%     value at the default font.  The previous version used
+%     $\backslash$let, which made $\backslash$DUT\@baselineskip a
+%     synonym for $\backslash$baselineskip that changed with font
+%     size.}
 %    \begin{macrocode}
-\let\DUT@baselineskip\baselineskip
+\newlength\DUT@baselineskip
+\setlength\DUT@baselineskip\baselineskip
 %    \end{macrocode}
 % \end{macro}
 %
 % requires \pkg{calc} for the multiplication.
 %    \begin{macrocode}
 \newcommand{\set@lines@length}[2]{%
-  \setlength{#1}{\DUT@baselineskip * {#2}}
-}
+  \setlength{#1}{\DUT@baselineskip * {#2}}}
 %    \end{macrocode}
 % \end{macro}
 %
 % Here we deviate from \file{ltsect.dtx} to ensure single spacing for
 % the section title.
 %    \begin{macrocode}
-    \begin{spacing}{\@ssp}
+      \setstretch{\@ssp}%
       #6{%
         \@hangfrom{\hskip #3\relax\@svsec}%
           \interlinepenalty \@M #8\@@par}%
-    \end{spacing}
     \endgroup
     \csname #1mark\endcsname{#7}%
     \addcontentsline{toc}{#1}{%
 % Here we deviate from \file{ltsect.dtx} to ensure single spacing for
 % the section title.
 %    \begin{macrocode}
-    \begin{spacing}{\@ssp}
+      \setstretch{\@ssp}%
       #4{%
         \@hangfrom{\hskip #1}%
           \interlinepenalty \@M #5\@@par}%
     \endgroup
-    \end{spacing}
   \else
     \def\@svsechd{#4{\hskip #1\relax #5}}%
   \fi
 %
 % \begin{command}
 %   `\cs{blanklines}\marg{N}'
+%   `\cs{blanklines*}\marg{N}'
 % \end{command}
 % \begin{macro}{\blanklines}
-% Insert \meta{N} blank lines.
+% Insert \meta{N} blank lines.  The starred forms use |\vspace|, which
+% inserts space even at the start and end of pages.  The |p| forms
+% add a trailing |\par|.  \emph{I'm still trying to get this part working
+% cleanly\ldots}
 %    \begin{macrocode}
 \newlength\DUT@blanklines@length
-\newcommand{\blanklines}[1]{%
-  \begin{spacing}{1}
-    \set@lines@length{\DUT@blanklines@length}{#1}%
-    \vspace{\DUT@blanklines@length}
-  \end{spacing}
+\newcommand{\@blanklines@setup}[1]{%
+  \set@lines@length{\DUT@blanklines@length}{#1}%
+  %\typeout{BLANKLINES -- #1}%
+  %\showthe\DUT@blanklines@length
 }
+\newcommand{\blanklines}{\@ifstar\@sblanklines\@blanklines}
+\newcommand{\@blanklines}[1]{%
+  \@blanklines@setup{#1}%
+  \vspace{\DUT@blanklines@length}}
+\newcommand{\@sblanklines}[1]{%
+  \@blanklines@setup{#1}%
+  \vspace*{\DUT@blanklines@length}}
+\newcommand{\blanklinesp}{\@ifstar\@sblanklines\@blanklines}
+\newcommand{\@blanklinesp}[1]{%
+  \@blanklines@setup{#1}%
+  \vspace{\DUT@blanklines@length}\par}
+\newcommand{\@sblanklinesp}[1]{%
+  \@blanklines@setup{#1}%
+  \vspace*{\DUT@blanklines@length}\par}
 %    \end{macrocode}
 % \end{macro}
 %
 %
+% \subsection{\pkg{hyperref} inclusion}
+% \label{sec:hyperref-inclusion}
+%
+% This is the awkward \pkg{hyperref} inclusion.  See
+% Section~\ref{sec:hyperref} for an explanation of why we stash it
+% here.
+%    \begin{macrocode}
+\RequirePackage[final]{hyperref}
+%    \end{macrocode}
+% Nobody likes the default colored boxes.  Color the text itself.
+%    \begin{macrocode}
+\hypersetup{colorlinks}
+%    \end{macrocode}
+%
+%
 % \subsection{\cls{book} overrides and extensions}
 %
 % Here we change the behavior of a bunch of macros and environments from
 % Here is the title text itself.
 %    \begin{macrocode}
     \begin{center}%
-    \begin{spacing}{\@tsp}
-      {\bfseries \@title \par}%
-    \end{spacing}
-    \begin{spacing}{\@dsp}
+      {\setstretch{\@tsp} \bfseries \@title \par}%
+%    \end{macrocode}
+% We want two blank lines (triple spacing) between the title and the
+% remaining material, so add three but don't end the paragraph.
+%    \begin{macrocode}
+      \blanklines{\@tsp}%
+      \setstretch{\@dsp}%
       A Thesis\\
       Submitted to the Faculty\\
       of\\
       Drexel University\\
       by\\
-      \@author \\
+      \@author\\
       in partial fulfillment of the\\
       requirements for the degree\\
       of\\
       \@degree\\
       \def@month\ \def@year
-    \end{spacing}
     \end{center}\par
 %    \end{macrocode}
 % Some more stretchy space for the bottom if we're not in draft mode.
     \copyright~Copyright \def@year\\
     \@author.  \@copyrighttext
   \end{center}
-  \if@final \vspace*{\fill} \else \blanklines{2} \fi
+  \if@final \vspace*{\fill} \else \blanklinesp{2} \fi
 %    \end{macrocode}
 % Turn off page numbering for this page.
 %    \begin{macrocode}
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\copyrighttextCC}
-% The Creative Commons license.
+% \begin{macro}{\copyrighttextCCBYSA}
+% The Creative Commons Attribution-ShareAlike License.
+% \changes{0.4}{2010/02/23}{W.~Trevor King renamed from
+% $\backslash$copyrighttextCC, and made specific to Creative Commons
+% Attribution-ShareAlike Version 3.0.}
 %    \begin{macrocode}
-\newcommand\copyrighttextCC{
+\newcommand\copyrighttextCCBYSA{
   \begin{quote}
     This work is licensed under the terms of the Creative Commons
-    Attribution-ShareAlike license.  The license is available at \\
+    Attribution-ShareAlike license Version 3.0.  The license is
+    available at \\
     \url{http://creativecommons.org/licenses/by-sa/3.0/}.
   \end{quote}
 }
 % (\file{classes.dtx}, L2053)
 %    \begin{macrocode}
 \renewcommand\chaptermark[1]{%
-  \markboth {\MakeUppercase{%
+  \markboth {%
     \ifnum \c@secnumdepth >\m@ne
       \if@mainmatter
         \@chapapp\ \thechapter: \ %
       \fi
     \fi
-    #1}}{}}
+    #1}{}}
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\schaptermark}
 % Setup unnumbered chapter marks for \pkg{fancyhdr}.
 %    \begin{macrocode}
-\newcommand\schaptermark[1]{\markboth{\MakeUppercase{#1}}{}}
+\newcommand\schaptermark[1]{\markboth{#1}{}}
 %    \end{macrocode}
 % \end{macro}
 %
 % (\file{classes.dtx}, L2054)
 %    \begin{macrocode}
 \renewcommand{\sectionmark}[1]{%
-  \markright {\MakeUppercase{%
+  \markright {%
     \ifnum \c@secnumdepth >\z@
       \thesection \ %
     \fi
-    #1}}}
+    #1}}
 %    \end{macrocode}
 % \end{macro}
 %
 % (\file{classes.dtx}, L2540).
 %    \begin{macrocode}
 \def\@makechapterhead#1{%
-  \blanklines{2}%
+%    \end{macro}
+% Adding even a \vspace*{0\p@} here seems to increase the vertical
+% space above the chapter heading by two lines.  I'm not sure why.
+% Workaround is to pass the ``value of blanklines you want minus two''
+% to |\blanklines*|.  HACK!
+%    \begin{macro}
+  \blanklines*{-1}%
   {\parindent \z@ \raggedright \normalfont
 %    \end{macrocode}
 % Ensure single spacing.
 %    \begin{macrocode}
-    \begin{spacing}{\@ssp}
+    \setstretch{\@ssp}%
 %    \end{macrocode}
 % Prevent a pagebreak from occuring in the middle of or after the title.
 %    \begin{macrocode}
     \else
       \center \large \bfseries #1\par\nobreak
     \fi
-    \end{spacing}
 %    \end{macrocode}
-% Put a little space before the chapter body.
+% Put a little space before the chapter body.  We use four blank lines
+% to comply with the Manual 3.13 p12
+% \begin{quote}
+%   Begin the list of sources four spaces below the heading.
+% \end{quote}
 %    \begin{macrocode}
-    \blanklines{2}
+    \blanklines{4}
   }
 }
 %    \end{macrocode}
 % (\file{classes.dtx}, L2595).
 %    \begin{macrocode}
 \def\@makeschapterhead#1{%
-  \blanklines{2}%
-  {\parindent \z@ \raggedright
-    \normalfont
+  \blanklines*{-1}% HACK!
+  {\parindent \z@ \raggedright \normalfont
+    \setstretch{\@ssp}%
     \interlinepenalty\@M
-    \begin{spacing}{\@ssp}
     \center \large \bfseries  #1\par\nobreak
-    \end{spacing}
-    \blanklines{2}
+    \blanklines{4}%
   }
 }
 %    \end{macrocode}
     \pdfbookmark[0]{\dedicationsname}{\dedicationsname}
   \fi
   \chapter*{\dedicationsname}
-  \begin{spacing}{\@dsp}
+  \setstretch{\@dsp}%
 }{%
-  \end{spacing}
+  \setstretch{\@ssp}%
 }
 %    \end{macrocode}
 % \end{environment}
     \pdfbookmark[0]{\acknowledgmentsname}{\acknowledgmentsname}
   \fi
   \chapter*{\acknowledgmentsname}
-  \begin{spacing}{\@dsp}
+  \setstretch{\@dsp}%
 }{%
-  \end{spacing}
+  \setstretch{\@ssp}%
 }
 %    \end{macrocode}
 % \end{environment}
 % \begin{environment}{abstract}
 %    \begin{macrocode}
 \newenvironment{abstract}{%
-  \listed@schapter{\abstractname}
+  \listed@schapter{\abstractname}%
 %    \end{macrocode}
-% From the Manual 3.9 p10 ``The following heading must be centered at
-% the top of the page'':
-% \begin{center}
-%   Abstract \\
-%   Full Title of Dissertation or Thesis \\
-%   Author's Name as it appears on the Dissertation or Thesis
-% \end{center}
-% In the example on p20, they list the advisor's name after the
-% author, but that is not specified in the text on p10.
-%
-% On p20, ``These pages are numbered using lowercase Roman numerals.
-% Note that the heading is single spaced, but the abstract is double
-% spaced.''
+% Suck up some blank space to position the rest of the header right
+% under the chapter title.
+%    \begin{macrocode}
+  \blanklines{-4}%
+%    \end{macrocode}
+% From the Manual 3.9 p10
+% \begin{quote}
+%   \begin{itemize}
+%     \item The following heading must be centered at the top of the page
+%       \begin{center}
+%         Abstract \\
+%         Full Title of Dissertation or Thesis \\
+%         Author's Name as it appears on the Dissertation or Thesis
+%       \end{center}
+%       In the example on p20, they list the advisor's name after the
+%       author, but that is not specified in the text on p10.
+%     \item The text begins four lines below this heading.
+%   \end{itemize}
+% \end{quote}
+% On p20
+% \begin{quote}
+%   \begin{itemize}
+%     \item These pages are numbered using lowercase Roman numerals.
+%     \item Note that the heading is single spaced, but the abstract
+%       is double spaced.
+%   \end{itemize}
+% \end{quote}
 %    \begin{macrocode}
-  \blanklines{-3}
-  \begin{spacing}{\@ssp}
     \begin{center}
+      \setstretch{\@ssp}%
       \@title\\
       \@author\\
       \@advisor\\
     \end{center}
-  \end{spacing}
-  \blanklines{2}
-  \begin{spacing}{\@dsp}
+  \blanklines{4}%
+  \setstretch{\@dsp}%
   \@nobreaktrue
   \@afterindentfalse
   \@afterheading
 }{%
-  \end{spacing}
+  \setstretch{\@ssp}%
 }
 %    \end{macrocode}
 % \end{environment}
 %    \begin{macrocode}
 \newenvironment{thesis}{%
   \mainmatter
-  \begin{spacing}{\@dsp}
+  \setstretch{\@dsp}%
 }{%
-  \end{spacing}
+  \setstretch{\@ssp}%
   \DUT@clearpage
   \ifpdf
     \phantomsection
 %    \begin{macrocode}
 \newenvironment{vita}{%
   \listed@schapter{\vitaname}
-  \blanklines{1}
-  \begin{spacing}{\@dsp}
+  \setstretch{\@dsp}%
 }{%
-  \end{spacing}
+  \setstretch{\@ssp}%
 }
 %    \end{macrocode}
 % \end{environment}
 %    \begin{macrocode}
 \renewenvironment{titlepage}{\thispagestyle{empty}%
                              \setcounter{page}\z@}%
-                            {\if@final \newpage \else \blanklines{2} \fi}
+                            {\if@final \newpage \else \blanklinesp{2} \par \fi}
 %    \end{macrocode}
 % \end{environment}
 %
 % We also turn on double spacing by default, since we're no longer
 % wrapped in the |thesis| environment.
 %    \begin{macrocode}
-  \setstretch{\@dsp}
+  \setstretch{\@dsp}%
 }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 % \end{macro}
 %
+% The default indents above are all |0pt|.  If \Lopt{indenttoc} was
+% given, override this, restoring the \pkg{tocloft} defaults, see the
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/tocloft/tocloft.pdf}{%
+%   \pkg{tocloft} manual, Table 1}.
+%    \begin{macrocode}
+\if@indenttoc
+  \cftsetindents{chapter}{0pt}{1.5em}
+  \cftsetindents{section}{1.5em}{2.3em}
+  \cftsetindents{subsection}{3.8em}{3.2em}
+  \cftsetindents{subsubsection}{7.0em}{4.1em}
+\fi
+%    \end{macrocode}
+%
 %
 % \subsubsection{List of figures}
 % \label{sec:implement-lof}
 %
 % \begin{macro}{\afterloftitleskip}
 % Don't add any extra space after the title (the chapter will take
-% care of that).
+% care of that).  Actually we make a one-line correction so the first
+% line matches the first line in the TOC.  HACK!
 %    \begin{macrocode}
-\setlength\cftafterloftitleskip{0pt}
+\setlength\cftafterloftitleskip{-12pt}
 %    \end{macrocode}
 % \end{macro}
 %
 %
 % \begin{macro}{\afterlottitleskip}
 % Don't add any extra space after the title (the chapter will take
-% care of that).
+% care of that).  Actually we make a one-line correction so the first
+% line matches the first line in the TOC.  HACK!
 %    \begin{macrocode}
-\setlength\cftafterlottitleskip{0pt}
+\setlength\cftafterlottitleskip{-12pt}
 %    \end{macrocode}
 % \end{macro}
 %
 % \end{macro}
 %
 % \subsubsection{Words}
+% \label{sec:words}
 %
 % Set the official names of the various sections encountered.  Some of
 % these are not defined in \file{classes.dtx} but are close analogs of
 %     \begin{macrocode}
 %<*example|example-draft>
 %% See drexel-thesis.pdf for details.
-%<example>\documentclass{drexel-thesis}
-%<example-draft>\documentclass[draft]{drexel-thesis}
+%<example>\documentclass[subfig]{drexel-thesis}
+%<example-draft>\documentclass[draft,subfig]{drexel-thesis}
 
 %% Enter the appropriate information here
 \author{Johny Henry}
 \advisor{Collis Potter Huntington, R.R.D.}
 \advisor{Advisor 2, Ph.D.}
 \advisor{Advisor 3, Ph.D.}
-\copyrighttext{\copyrighttextCC}
+\copyrighttext{\copyrighttextCCBYSA}
 
 \usepackage[super,sort&compress]{natbib} % fancy citation extensions
 \bibliographystyle{unsrtnat}
 \usepackage{fancyvrb} % nicer verbatim handling
 \DefineShortVerb{\|}  % \verb+TEXT+  ->  |TEXT|
 
-\usepackage{blabla} % \blabla macro for producing dummy output
+%     \end{macrocode}
+% Use
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/blindtext/}{\pkg{blindtext}}
+% for dummy text creation.  \pkg{blindtext} requires
+% \href{}{\pkg{babel}}.
+%     \begin{macrocode}
+\usepackage[english]{babel} % English blindtext
+\usepackage{blindtext} % macros for producing dummy output
+%     \end{macrocode}
+% \pkg{babel} messes with some of our words (Section \ref{sec:words}), so
+% we have to reset them.  See the
+% \href{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=latexwords}{\TeX\ FAQ}
+% for details.
+%     \begin{macrocode}
+\addto\captionsenglish{%
+  \renewcommand\dedicationsname{Dedications}%
+  \renewcommand\acknowledgmentsname{Acknowledgments}%
+  \renewcommand\contentsname{Table of Contents}%
+  \renewcommand\listtablename{List of Tables}%
+  \renewcommand\listfigurename{List of Figures}%
+  \renewcommand\abstractname{Abstract}%
+  \renewcommand\bibname{Bibliography}%
+  \renewcommand\appendixname{Appendix}%
+  \renewcommand\vitaname{Vita}%
+}
 
 \begin{document}
 \begin{preamble}
 
 \begin{dedications}
-\blabla{10}{20}
+\Blindtext{10}{10}
 \end{dedications}
 
 \begin{acknowledgments}
-\blabla{10}{20}
+\Blindtext{10}{10}
 \end{acknowledgments}
 
 \tableofcontents
 \listoffigures
 
 \begin{abstract}
-\blabla{10}{20}
+\Blindtext{10}{10}
 \end{abstract}
 \end{preamble}
 
 \include{example-a}
 
 \begin{vita}
-\blabla{10}{20}
+\Blindtext{10}{10}
 \end{vita}
 
 \end{document}
 %
 %
 % \subsubsection{Part}
+% \label{section:better-example-part}
 %
 %     \begin{macrocode}
 %<*example-part>
@@ -2696,7 +2985,7 @@ Here we have a text citation \citet{rief97} followed by a
 parenthetical citation\citep{rief97}.
 
 \subsubsection{Tables and Figures}
-\blabla{2}{20}
+\Blindtext{2}{20}
 \begin{table}
   \begin{center}
   \begin{tabular}{r@{.}l r@{.}l r@{.}l}
@@ -2708,7 +2997,7 @@ parenthetical citation\citep{rief97}.
     30&0 & 11&9 & 10&1 \\
     \ldots
   \end{tabular}
-  \caption{A table float. \bla{20}}  % low caption allowed with floatrow
+  \caption{A table float.} %\blindtext{20}}  % low caption allowed with floatrow
 %% 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}).
@@ -2717,21 +3006,37 @@ parenthetical citation\citep{rief97}.
 %% to span the pre- and post-decimal columns.
   \end{center}
 \end{table}
-\blabla{5}{20}
+\Blindtext{5}{20}
 \begin{figure}
-  \caption{A figure float. \bla{20}} % high caption allowed with floatrow
+  \caption{A figure float. \blindtext{20}} % high caption allowed with floatrow
   \begin{center}
     \includegraphics[width=0.4\textwidth]{drexel-logo}
   \end{center}
 \end{figure}
-\blabla{10}{20}
+\Blindtext{10}{20}
+\begin{figure}
+  \begin{center}
+    \subfloat[][]{%
+      \includegraphics[width=0.2\textwidth]{drexel-logo}%
+      \label{fig:sub-a}}
+    \subfloat[][]{%
+      \includegraphics[width=0.2\textwidth]{drexel-logo}%
+      \label{fig:sub-b}}
+    \caption{(a) One subfig float. (b) Another subfig float.%
+      \label{fig:both}}
+  \end{center}
+\end{figure}
+You can reference the subfig floats individually (\ref{fig:sub-a}) or
+together (\ref{fig:both}).
+
+\Blindtext{10}{20}
 
 \part{Another Part}
 \chapter{Another Chapter}
-\blabla{30}{20}
+\Blindtext{30}{20}
 \chapter{A Long Title Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla
 Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla}
-\blabla{30}{20}
+\Blindtext{30}{20}
 %</example-part>
 %    \end{macrocode}
 %
@@ -2800,42 +3105,54 @@ Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla}
 %    \begin{macrocode}
 %<*example-appendix>
 \chapter{Some Appendix Heading}
-\blabla{10}{20}
+\Blindtext{10}{20}
 \chapter{Another Appendix Heading}
-\blabla{10}{20}
+\Blindtext{10}{20}
 %</example-appendix>
 %    \end{macrocode}
 %
 %
-% \subsubsection{\pkg{blabla}}
+% \section{Known bugs and issues}
 %
-% 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]
-%    \end{macrocode}
-% Use
-% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/forloop/}{\pkg{foorloop}}
-% for
-% \begin{command}
-%   `\cs{forloop}\oarg{step}\marg{counter}\marg{initial value}\marg{condition}\marg{code}'
-% \end{command}
-%    \begin{macrocode}
-\RequirePackage{forloop}[2006/09/18]
-
-\newcounter{blabla@i}
-\newcounter{blabla@j}
-\newcommand{\bla}[1]{
-   Bla
-  \forloop{blabla@i}{0}{\value{blabla@i} < #1}{ bla }
-  bla.
-}
-\newcommand{\blabla}[2]{
-  \forloop{blabla@j}{0}{\value{blabla@j} < #1}{ \bla{#2}\par }
-}
-%</blabla>
-%    \end{macrocode}
+%
+% \subsection{Hacks}
+%
+% \begin{itemize}
+%   \item |\vspace*{0\p@}| space between page top and chapter
+%     headings (|\@makechapterhead| and |\@makeschapterhead|,
+%     Sec.~\ref{sec:implement-chapters}).
+%   \item Extra space under LOT and LOF titles compared to TOC.
+%     (Secs.~\ref{sec:implement-lof} and \ref{sec:implement-lot}).
+% \end{itemize}
+%
+%
+% \subsection{Bugs}
+%
+% \begin{itemize}
+%   \item Different space between chapter heading and section heading,
+%     vs.\ chapter heading and text.  Compare \emph{A Chapter Heading}
+%     and \emph{Another Chapter} in \file{example.pdf}.  This is a
+%     problem (although with opposite order) in the \cls{book} class
+%     itself.  For example, compile
+%     \begin{example}
+%\documentclass{book}
+%\begin{document}
+%\chapter{Chapter with text}
+%Bla bla bla.
+%\chapter{Chapter with section}
+%\section{Section}
+%Bla bla bla.
+%\end{document}
+%     \end{example}
+%   \item Footer overlap if chapter/section names are particularly long.
+%     See \emph{Section in long-titled chapter} in \file{example.pdf}.
+%     Workaround: turn off sections in the footer:
+%     \begin{example}
+%       \fancyfoot[RE,LO]{\scshape\leftmark}
+%       \fancyfoot[LE,RO]{}
+%     \end{example}
+%     For more header or footer manipulation ideas, see Section \ref{sec:fancyhdr}.
+% \end{itemize}
 %
 %
 % \Finale