From 12ee6441cd6cc9df8822760fc49d2626470b6fcf Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 12 Jan 2010 09:38:13 -0500 Subject: [PATCH] Merged Evan Sultanik's December 2009 multiple-advisor drexelthesis.cls. Changes vs. Evan's implementation * use \expandafter to avoid involving \@mainaux * use already-defined \alph{} rather roll-your-own \@alphabet * many advisors case printed "A, B, and C" rather than "A, B and C". Unrelated changes * \@advisor -> \@degree typo fix. * \@sect and \@ssect pseudocode now in |example| environment. * natbib's unsrt analog is unsrtnat, not plainnat. Finally, I packaged the whole thing into \@advisor, so the compositing logic can be used in multiple places Evan's original patch was: --- drexelthesis.cls-old +++ drexelthesis.cls @@ -1,5 +1,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Drexel University Thesis LaTeX2e Class definition. +% Modified by Evan Sultanik December 2009 % Modified by Jeff Abrahamson May 2007 % Modified by Evan Sultanik April 2006 % Modified by Jeff Abrahamson May 2005 @@ -462,14 +463,16 @@ \newcommand{\department}[1]{\ifx\empty#1\else\gdef\@department{#1}\fi} \newcommand{\degree}[1]{\ifx\empty#1\else\gdef\@degree{#1}\fi} \renewcommand{\author}[1]{\ifx\empty#1\else\gdef\@author{#1}\fi} -\newcommand{\advisor}[1]{\ifx\empty#1\else\gdef\@advisor{#1}\fi} +\newcommand{\advisor}[1]{\ifx\empty#1\else\refstepcounter{numadvisors}\immediate\write\@mainaux + {\string\gdef\string\@advisor\alph{numadvisors}{#1}}\fi} \renewcommand{\title}[1]{\ifx\empty#1\else\gdef\@title{#1}\fi} \newcommand{\gyear}[1]{\ifx\empty#1\else\gdef\@gyear{#1}\fi} \global\def\@department{\mbox{}} \global\def\@degree{\mbox{}} \global\def\@author{\mbox{}} -\global\def\@advisor{\mbox{}} +\newcounter{numadvisors} +\setcounter{numadvisors}{0} \global\def\@title{\mbox{}} \global\def\@gyear{\number\year} % Default year is current year @@ -655,6 +658,7 @@ {\@latex@warning{Empty `thebibliography' environment}}% \endlist \clearpage} +\def\@alphabet#1{\ifcase#1a\or a\or b\or c\or d\or e\or f\or g\else h\fi} \renewenvironment{abstract}{ \clearemptydoublepage \phantomsection @@ -665,7 +669,17 @@ \vspace*{-1em} {\@title}\\[3mm] {\@author}\\ - {\smallskip Advisor: \@advisor}\\ + {\smallskip Advisor\ifnum\thenumadvisors>1 s\fi: + \begingroup + \newcount\adv + \adv=0 + \loop + \ifnum\adv<\thenumadvisors + \advance\adv by 1 + \ifnum\thenumadvisors>1\ifnum\adv=\thenumadvisors{\ and\ }\else\ifnum\adv>1{,\ }\fi\fi\fi + \csname @advisor\@alphabet{\the\adv}\endcsname\relax + \repeat + \endgroup}\\ \vspace*{4em} } \end{singlespace} --- drexel-thesis.dtx | 107 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 90 insertions(+), 17 deletions(-) diff --git a/drexel-thesis.dtx b/drexel-thesis.dtx index b5b91b8..666aaef 100644 --- a/drexel-thesis.dtx +++ b/drexel-thesis.dtx @@ -246,6 +246,12 @@ % \begin{example} % \advisor{John A. Wheeler, Ph.D.} % \end{example} +% You can set multiple advisors, if appropriate, by calling |\advisor| +% multiple times. +% \begin{example} +% \advisor{John A. Wheeler, Ph.D.} +% \advisor{Advisor 2} +% \end{example} % See the Manual 3.1 p8. % % \begin{command} @@ -875,17 +881,6 @@ % % 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} -\def\advisor#1{\gdef\@advisor{#1}} -\def\@advisor{\@latex@error{No \noexpand\advisor given}\@ehc} -% \end{macrocode} -% \end{macro} -% \end{macro} -% % \begin{macro}{\defmonth} % \begin{macro}{\@defmonth} % |\defmonth| (defense month) for use in |\maketitle|. If not given @@ -915,7 +910,7 @@ % \begin{macrocode} \def\degree#1{\gdef\@degree{#1} \ifpdf \hypersetup{pdfsubject={\@degree}} \fi} -\def\@advisor{\@latex@error{No \noexpand\degree given}\@ehc} +\def\@degree{\@latex@error{No \noexpand\degree given}\@ehc} % \end{macrocode} % \end{macro} % \end{macro} @@ -931,6 +926,82 @@ % \end{macro} % \end{macro} % +% \begin{macro}{\advisor} +% \begin{macro}{\@advisor} +% |\advisor| for use in |\maketitle|. If not given |\maketitle| will +% produce an error message. We get a bit fancier here to support +% multiple advisors. +% \begin{macrocode} +\newcounter{advisors} +\setcounter{advisors}{0} +\newcommand\advisor[1]{% + \ifx +% \end{macrocode} +% If |#1| is |\empty|, this call is a no-op. +% \begin{macrocode} + \empty{#1} + \else +% \end{macrocode} +% Save the advisors to |\@advisor@a|, |\@advisor@b|, \ldots. +% |\alph{|\Lcount{COUNTER}|}| (\file{ltcounts.dtx}, L319) prints the +% value of \Lcount{COUNTER} as a lowercase letter: $1 =$~a, $2 =$~ +% b, etc. +% \begin{macrocode} + \stepcounter{advisors} + \expandafter\gdef\csname @advisor@\alph{advisors}\endcsname{#1} + \fi} +\newcommand\@advisor{% + \ifnum\c@advisors=0% + \@latex@error{No \noexpand\advisor given}\@ehc% + \else% +% \end{macrocode} +% Start a group so \Lcount{advisor@loop} is released afterwards to +% save memory. +% \begin{macrocode} + \begingroup% + \newcounter{advisor@loop}% + \setcounter{advisor@loop}{1}% +% \end{macrocode} +% Print the first advisor. +% \begin{macrocode} + \csname @advisor@\alph{advisor@loop}\endcsname\relax% +% \end{macrocode} +% For any remaining advisors\ldots +% \begin{macrocode} + \loop\ifnum\c@advisor@loop<\c@advisors% + \stepcounter{advisor@loop}% +% \end{macrocode} +% Print the connecting text. +% \begin{macrocode} + \ifnum\c@advisor@loop=\c@advisors% + \ifnum\c@advisors=2% +% \end{macrocode} +% The next advisor if the last of two. +% \begin{macrocode} + {\ and\ }% + \else% +% \end{macrocode} +% The next advisor if the last of many. +% \begin{macrocode} + {, and\ }% + \fi% + \else% +% \end{macrocode} +% The next advisor is not the last. +% \begin{macrocode} + {,\ }% + \fi% +% \end{macrocode} +% Print the advisor's name. +% \begin{macrocode} + \csname @advisor@\alph{advisor@loop}\endcsname\relax% + \repeat% + \endgroup% + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% % % \begin{command} % `\cs{AddContentsLine}\marg{table}\marg{type}\marg{notcap}\marg{entry}' @@ -1012,7 +1083,7 @@ % % \begin{macro}{\@sect} % Pseudocode for the |\@sect| command -% \begin{macrocode} +% \begin{example} % \@sect{NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}[ARG1]{ARG2} % == % BEGIN @@ -1046,7 +1117,7 @@ % FI % \@xsect{AFTERSKIP} % END -% \end{macrocode} +% \end{example} % (\file{ltsect.dtx}, L295). % \begin{macrocode} \def\@sect#1#2#3#4#5#6[#7]#8{% @@ -1092,7 +1163,7 @@ % % \begin{macro}{\@ssect} % Pseudocode for the |\@ssect| command -% \begin{macrocode} +% \begin{example} % \@ssect{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}{ARG} == % BEGIN % IF AFTERSKIP > 0 @@ -1107,7 +1178,7 @@ % FI % \@xsect{AFTERSKIP} % END -% \end{macrocode} +% \end{example} % (\file{ltsect.dtx}, L521). % \begin{macrocode} \def\@ssect#1#2#3#4#5{% @@ -2662,10 +2733,12 @@ \defyear{1872} \degree{Doctor of Philosophy} \advisor{Collis Potter Huntington, R.R.D.} +\advisor{Advisor 2, Ph.D.} +\advisor{Advisor 3, Ph.D.} \copyrighttext{\copyrighttextCC} \usepackage[super,sort&compress]{natbib} % fancy citation extensions -\bibliographystyle{plainnat} +\bibliographystyle{unsrtnat} \usepackage{fancyvrb} % nicer verbatim handling \DefineShortVerb{\|} % \verb+TEXT+ -> |TEXT| -- 2.26.2