Work around potential \chapter{Bla bla\label{x}} usage.
[drexel-thesis.git] / drexel-thesis.dtx
index 904e7f483863cd1d91268c38ddf91ffaa6cc6a0e..97127483aa63b2ba9ea2b0f289913aa4f9b65fde 100644 (file)
@@ -1,8 +1,8 @@
-% \def\fileversion{0.7}
-% \def\filedate{2010/03/14}
+% \def\fileversion{0.8}
+% \def\filedate{2010/05/20}
 % \iffalse meta-comment
-%<class>\def\fileversion{0.7}
-%<class>\def\filedate{2010/03/14}
+%<class>\def\fileversion{0.8}
+%<class>\def\filedate{2010/05/20}
 %
 % Copyright (C) 2010  C.Y. Ip
 %                     Christopher D. Cera
 % bookmark is set at the \emph{part} level (-1) to hold all bookmarks
 % from the |preamble| environment, since those entries are all
 % chapters.
+% \changes{0.8}{2010/05/20}{W.~Trevor King replaced Titlepage with
+%   Title Page for consistency with \LaTeX's book class.}
 %    \begin{macrocode}
     \ifpdf
-      \pdfbookmark[-1]{Frontmatter}{Frontmatter}
+      \pdfbookmark[-1]{Front Matter}{Front Matter}
       \pdfbookmark[0]{Title Page}{Title Page}
     \fi
 %    \end{macrocode}
 % \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.
+% |\@mainmatter| is true if and only if we are processing main
+% matter\footnote{%
+%   \href{http://en.wikipedia.org/wiki/Book_design}{Wikipedia}
+%   suggests \emph{body matter} for the main content, but
+%   \href{http://mirror.ctan.org/macros/latex/base/classes.dtx}{\LaTeX's
+%   \cls{book}} uses \emph{Main Matter}.  We're a \LaTeX\ class, so
+%   we'll stick with ``main matter'' for consistency.
+% }.  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
 % we display the chapter number.
 % We drop \cls{book}'s \Lopt{twocolumn} code. 
 % (\file{classes.dtx}, L2496).
-% \begin{macrocode}
+%    \begin{macrocode}
 \def\@chapter[#1]#2{
-% \end{macrocode}
+%    \end{macrocode}
 % Inform the user that a new chapter is about to be typeset by writing
 % a message to the terminal.
-% \begin{macrocode}
+% \changes{0.9}{2010/05/21}{W.~Trevor King. disabled the label macro
+% for typeout.}
+% Some users place |\label| in their chapter argument:
+% \begin{example}
+%   \chapter{Bla bla\label{x}}
+% \end{example}
+% rather than after (as recommended by
+% \href{http://en.wikibooks.org/wiki/LaTeX/Labels_and_Cross-referencing#Sections}%
+%   {the \LaTeX\ Wikibook} and
+% \href{http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf}%
+%   {The Not So Short Introduction to \LaTeXe\ (section 2.8, p36)}):
+% \begin{example}
+%   \chapter{Bla bla}
+%   \label{x}
+% \end{example}
+% The embedded |\label| chokes |\typeout| so we temporarily redefine
+% |\label| to just gobble its contents.  |\DUT@label| stores the
+% original definition.
+%    \begin{macrocode}
+  \let\DUT@label=\label%
+  \renewcommand{\label}[1]{}%
   \typeout{\@chapapp\space\thechapter. #1}%
+%    \end{macrocode}
+% Restore |\label| to its previous glory.
+%    \begin{macrocode}
+  \let\label=\DUT@label%
+%    \end{macrocode}
+% Now we can get on with the real work.
+%    \begin{macrocode}
   \ifnum \c@secnumdepth >\m@ne
     \if@mainmatter
       \refstepcounter{chapter}%
 % (\file{classes.dtx}, L2582).
 %    \begin{macrocode}
 \def\@schapter#1{
-% \end{macrocode}
+%    \end{macrocode}
 % Inform the user that a new chapter is about to be typeset by writing
 % a message to the terminal.
-% \begin{macrocode}
+%    \begin{macrocode}
   \typeout{\@chapapp\space #1}%
   \schaptermark{#1}%
   \@makeschapterhead{#1}%
 }{%
   \setstretch{\@ssp}%
   \DUT@clearpage
+%    \end{macrocode}
+% \changes{0.8}{2010/05/20}{W.~Trevor King replaced Titlepage with
+%   Title Page for consistency with \LaTeX's book class.}
+%    \begin{macrocode}
   \ifpdf
     \phantomsection
-    \pdfbookmark[-1]{Backmatter}{Backmatter}
+    \pdfbookmark[-1]{Back Matter}{Back Matter}
   \fi
 }
 %    \end{macrocode}
 \end{preamble}
 
 \begin{thesis}
+%% If your thesis does not use \part{}s, you may want to add a
+%% part-level PDF bookmark to set the main matter of from the front
+%% matter.
+%%\pdfbookmark[-1]{Main Matter}{Main Matter}
+
 %% Use include statements to include your main thesis code
 %% from seperate files.
 %%\include{part1}