Cleaned up use of substring$
[latex-mlastyle.git] / mlastyle.dtx
index 35b9aa5faff2fbc8f2535eef605bc67e448fc477..dd60132c8bffee67a25d97bd19271409772644f5 100644 (file)
@@ -262,10 +262,10 @@ Schlegl",
 % \DoNotIndex{\parindent}
 % \DoNotIndex{\parsep}
 % \DoNotIndex{\penalty}
+% \DoNotIndex{\protected@xdef}
 % \DoNotIndex{\relax}
 % \DoNotIndex{\renewcommand}
 % \DoNotIndex{\renewenvironment}
-% \DoNotIndex{\reset@font}
 % \DoNotIndex{\rhead}
 % \DoNotIndex{\selectfont}
 % \DoNotIndex{\setlength}
@@ -619,7 +619,7 @@ Schlegl",
 %    \begin{macrocode}
 \def\surname#1{\gdef\mlastyle@surname{#1}}
 \def\mlastyle@surname{\def\ml@##1 ##2,##3@@{##2}%
-  \expandafter\ml@\@author, ,@@}
+  \def\and##1 {\unskip, }\expandafter\ml@\@author, ,@@}
 \let\lastname\surname
 %    \end{macrocode}
 % \end{macro}
@@ -636,9 +636,9 @@ Schlegl",
 % \end{macro}
 % \subsubsection{Macros}
 % \begin{macro}{\maketitle}
+% \begin{macro}{\and}
 % |\maketitle| generates a heading in MLA format.
 %    \begin{macrocode}
-  \let\and\\
   \renewcommand{\maketitle}{\begin{flushleft}
     \@author\par
     \@ifundefined{mlastyle@instructor}{}{\mlastyle@instructor}\par
@@ -646,8 +646,10 @@ Schlegl",
     \@date\end{flushleft}
     \begin{center}\@title\end{center}\par
   }
+  \let\and\par
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 % \begin{macro}{\today}
 % |\today| is redefined to DD~Mon.~YYYY format.
 %    \begin{macrocode}
@@ -878,19 +880,18 @@ Schlegl",
 % \subsection{Style}
 % \begin{macro}{\bibstyle@mlastyle}
 % This first block is the beginnings of an implementation for
-% \package{natbib}.  Surely there is a better way.
+% \package{natbib}.  (Surely there is a better way.)
 %    \begin{macrocode}
 \newcommand{\bibstyle@mlastyle}{%
   \bibpunct[\mlastyle@space]{\mlastyle@brack(}{\mlastyle@brack)}%
-    {;}{a}{\mlastyle@comma}{,}
+    {\unskip;}{a}{\mlastyle@comma}{,}
   \gdef\mlastyle@brack##1{\ifx\NAT@date\mlastyle@notitle
     \ifmlastyle@pages ##1\else\ifNAT@swa\ifnum
     \NAT@ctype=0 ##1\else\unskip\fi\else\unskip\fi\fi\else ##1\fi}
   \gdef\mlastyle@comma{\ifx\NAT@date\mlastyle@notitle\else,\fi}
-  \gdef\mlastyle@space{\ifx\NAT@date\mlastyle@notitle{}\else{} \fi}
   \gdef\mlastyle@space{\ifx\NAT@date\mlastyle@notitle
-    \ifnum\NAT@ctype<2
-      \ifNAT@par\ifNAT@swa{} \fi\else{} \fi\fi\else{} \fi}
+  \ifnum\NAT@ctype=1{} \fi\else{} \fi}
+%      \ifNAT@par\ifNAT@swa{} \fi\else{} \fi\fi\else{} \fi}
     \gdef\citetext##1{(##1)}
   \@ifundefined{chapter}
   {\gdef\refname{Works Cited}}
@@ -901,7 +902,7 @@ Schlegl",
 % This hack represents an empty title in the MLA bibliography style.
 %    \begin{macrocode}
 \def\mlastyle@notitle
-  { \ \ \ \ \unskip\unskip\unskip\unskip\unskip\unskip}
+  { \ \ \ \ \unskip\unskip\unskip\unskip\unskip}
 \RequirePackage{natbib}
 \newif\ifmlastyle@pages
 \renewcommand\NAT@citetp
@@ -938,6 +939,7 @@ Schlegl",
 % executed.
 %    \begin{macrocode}
 \ifmlastyle@style
+%    \end{macrocode}
 % If the \Lopt{bibstyle} option is set, specify the bibliography style.
 %    \begin{macrocode}
   \ifmlastyle@bibstyle
@@ -948,13 +950,27 @@ Schlegl",
 %    \begin{macrocode}
   \let\cite\citep
   \let\mlastyle@citequeue\empty
-  %\newcommand\citeflush{\ifx\mlastyle@citequeue\@empty\unskip
-    %\else\citetext{\mlastyle@citequeue}\global
-    %\let\mlastyle@citequeue\@empty\fi}
-  %\newcommand\citeadd[2][]{\ifx\mlastyle@citequeue\@empty
-    %\protected@xdef\mlastyle@citequeue{\citealp[#1]{#2}}\else
-    %\protected@xdef\mlastyle@citequeue{\mlastyle@citequeue\NAT@sep
-    %\ {\citealp[#1]{#2}}\fi}
+  \def\mlastyle@cite#1#2#3{\csname#1\endcsname[#2]{#3}}
+  \newcommand\citeflush{\ifhmode\unskip\fi
+    \ifx\mlastyle@citequeue\@empty\else{} \let\@citea\relax
+    \citetext{\@for\@citeb:=\mlastyle@citequeue\do{\@citea
+    \expandafter\mlastyle@cite\@citeb\def\@citea{\NAT@sep\ }}}%
+    \global\let\mlastyle@citequeue\@empty\fi}
+  \newcommand\mlastyle@citeadd[3]{\ifx\mlastyle@citequeue\@empty
+    \xdef\mlastyle@citequeue{{#1}{#2}{#3}}\else
+    \xdef\mlastyle@citequeue{\mlastyle@citequeue,%
+    {#1}{#2}{#3}}\fi}
+  \newcommand\citeadd[2][]{\mlastyle@citeadd{citealp}{#1}{#2}}
+  \newcommand\citea{\@ifstar
+    {\let\mlastyle@star*\mlastyle@citea}
+    {\let\mlastyle@star\empty\mlastyle@citea}}
+  \newcommand\mlastyle@citea[2][]{\expandafter\citeauthor
+    \mlastyle@star{#2}\mlastyle@citeadd{citeyear}{#1}{#2}}
+  \newcommand\Citea{\@ifstar
+    {\let\mlastyle@star*\mlastyle@Citea}
+    {\let\mlastyle@star\empty\mlastyle@Citea}}
+  \newcommand\mlastyle@Citea[2][]{\expandafter\Citeauthor
+    \mlastyle@star{#2}\mlastyle@citeadd{citeyear}{#1}{#2}}
   \newcommand\citepage[2][]{\citeyearpar[#1]{#2}}
   \newcommand\citepageM[2][]{\unskip{} \citeyearpar[#1]{#2}}
   \newcommand\citeindirect[2][]{\citep[qtd.\ in][#1]{#2}}