Use hypcap (and bump to v0.5)
[drexel-thesis.git] / drexel-thesis.dtx
index 13bae3a01be1142b7999c1f56e371c154cd19304..93637cc9af2fd2c92dd87914781a511c240516ad 100644 (file)
@@ -1,8 +1,8 @@
-% \def\fileversion{0.3}
-% \def\filedate{2010/01/13}
+% \def\fileversion{0.5}
+% \def\filedate{2010/03/03}
 % \iffalse meta-comment
-%<class>\def\fileversion{0.3}
-%<class>\def\filedate{2010/01/13}
+%<class>\def\fileversion{0.5}
+%<class>\def\filedate{2010/03/03}
 %
 % Copyright (C) 2010  C.Y. Ip
 %                     Christopher D. Cera
 %   Based on the University of Toronto Thesis \LaTeXe\ Class.  Also
 %   greatly improved the documentation by incorperating bits of
 %   the base/*.dtx files.}
+% \changes{0.5}{2010/03/03}{W.~Trevor King use hypcap for better
+%   caption hyperlink anchor placement.}
 %
 % \MakeShortVerb{\|}
 % \newcommand{\pkg}[1]{\textsf{#1}}
 %   \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
 % 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}
 % \href{http://www.ctan.org/tex-archive/macros/latex/required/graphics/}{\pkg{graphicx}}
 % to define the |\includegraphics| macro,
 % \href{http://www.ctan.org/tex-archive/macros/latex/required/caption/}{\pkg{caption}}
-% for pretty caption formatting, and
+% for pretty caption formatting,
 % \href{http://www.ctan.org/tex-archive/macros/latex/required/floatrow/}{\pkg{floatrow}}
-% for placing captions.
+% for placing captions, and
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/}{\pkg{hypcap}}
+% for placing caption anchors.
 %
 % Simple float definitions will look like
 % \begin{example}
 %      \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}.
 %
-% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/subfig/}{\pkg{subfig}}
-% cooperates with \cls{drexel-thesis}'s included \pkg{floatrow}.  If
-% you wish to use the \pkg{subfig} macros, you should add something
-% like
-% \begin{example}
-%   \usepackage{subfig}
-%   \usepackage{fr-subfig}
-% \end{example}
-% See the \pkg{floatrow} documentation (Sec.~7.1, ``The \pkg{subfig}
-% package'') and \pkg{subfig} documentation (Sec.~4.3,
-% ``\pkg{FloatRow} Package'') for details.
-%
 %
 % \subsubsection{Citations}
 %
 % \href{http://www.ctan.org/tex-archive/macros/latex/contrib/cleveref/}{\pkg{cleveref}}.
 % 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}
 % 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}
 % 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
 }
 %    \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}}
 %
 % |\author|, etc.\ to avoid using |\AtBeginDocument| or some such.
 %
 %
+% \subsubsection{\pkg{hypcap}}
+%
+% \href{http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/}{\pkg{hypcap}}
+% for placing caption hyperlink anchors.  Not strictly necessary, but
+% we're using \pkg{hyperref}, and the poor link targets are annoying.
+%    \begin{macrocode}
+\RequirePackage[all]{hypcap}
+%    \end{macrocode}
+% \Lopt{all} redefines the figure and table environments to
+% place the anchor at the start of the float.
+%
+%
 % \subsection{\LaTeX\ overrides and extensions}
 %
 % Here we change the behavior of a bunch of macros and environments
 %    \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
+% \\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}
 }
 % \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}
 % \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>
@@ -2853,7 +2982,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}
@@ -2865,7 +2994,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}).
@@ -2874,23 +3003,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}
-\section{Section in long-titled chapter}
-\blabla{30}{20}
+\Blindtext{30}{20}
 %</example-part>
 %    \end{macrocode}
 %
@@ -2959,44 +3102,13 @@ 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}}
-%
-% 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}
-%
-%
 % \section{Known bugs and issues}
 %
 %
@@ -3031,11 +3143,12 @@ Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla Bla}
 %     \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 either chapters or sections in the footer.
+%     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}
 %
 %