Swapped style and format sections
authorTim Pope <code@tpope.net>
Sat, 22 Nov 2003 01:26:12 +0000 (01:26 +0000)
committerTim Pope <code@tpope.net>
Sat, 22 Nov 2003 01:26:12 +0000 (01:26 +0000)
Unified article and book bibliography environments
Added DoNotIndex entries

mlastyle.dtx

index dd60132c8bffee67a25d97bd19271409772644f5..9710bc276af501d5c7293672e7cc4e1806ebd6f4 100644 (file)
@@ -125,18 +125,15 @@ Schlegl",
 %
 % \DoNotIndex{\ }
 % \DoNotIndex{\.}
-% \DoNotIndex{\@afterindentfalse}
-% \DoNotIndex{\@afterindenttrue}
+% \DoNotIndex{\@afterindentfalse,\@afterindenttrue}
 % \DoNotIndex{\@arabic}
 % \DoNotIndex{\@author}
 % \DoNotIndex{\@auxout}
-% \DoNotIndex{\@citea}
-% \DoNotIndex{\@citeb}
+% \DoNotIndex{\@citea,\@citeb}
 % \DoNotIndex{\@date}
 % \DoNotIndex{\@empty}
-% \DoNotIndex{\@firstofone}
 % \DoNotIndex{\@for}
-% \DoNotIndex{\@ifundefined}
+% \DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined}
 % \DoNotIndex{\@latex@warning}
 % \DoNotIndex{\@listI}
 % \DoNotIndex{\@listi}
@@ -153,6 +150,7 @@ Schlegl",
 % \DoNotIndex{\DeclareOption}
 % \DoNotIndex{\ExecuteOptions}
 % \DoNotIndex{\G@refundefinedtrue}
+% \DoNotIndex{\NAT@@citetp,\NAT@citetp,\NAT@ctype,\NAT@date,\NAT@sep}
 % \DoNotIndex{\ProcessOptions}
 % \DoNotIndex{\RequirePackage}
 % \DoNotIndex{\UL@start,\UL@stop}
@@ -623,6 +621,141 @@ Schlegl",
 \let\lastname\surname
 %    \end{macrocode}
 % \end{macro}
+
+% \subsection{Style}
+% \begin{macro}{\bibstyle@mlastyle}
+% This first block is the beginnings of an implementation for
+% \package{natbib}.  (Surely there is a better way to do this.)
+%    \begin{macrocode}
+\newcommand{\bibstyle@mlastyle}{%
+  \bibpunct[\mlastyle@space]{\mlastyle@brack(}{\mlastyle@brack)}%
+    {\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
+  \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}}
+  {\gdef\bibname{Works Cited}}}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mlastyle@notitle}
+% This hack represents an empty title in the MLA bibliography style.
+%    \begin{macrocode}
+\def\mlastyle@notitle
+  { \ \ \ \ \unskip\unskip\unskip\unskip\unskip}
+\RequirePackage{natbib}
+\newif\ifmlastyle@pages
+\renewcommand\NAT@citetp
+{\@ifnextchar[{\mlastyle@pagestrue\NAT@@citetp}%
+  {\mlastyle@pagesfalse\NAT@@citetp[]}}
+%    \end{macrocode}
+%\end{macro}
+% \begin{macro}{\cite}
+% \begin{macro}{\citealp}
+% ^^A\begin{macro}{\citepage}
+% ^^A\begin{macro}{\citequote}
+% The following macros, combined with \file{mlastyle.bst}, provide
+% for a bibliography in MLA style.  Note that the definition of |\cite|,
+% |\citealp|, etc.\ vary depending on the options passed to
+% \package{mlastyle}.
+%
+% \begin{macro}{\mlastyle@intcite}
+% The original |\cite| is stored
+% in |\mlastyle@intcite|.
+%    \begin{macrocode}
+%\let\mlastyle@intcite\cite
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\mlastyle@relax}
+% This macro does nothing.  Depending on the options, either |\citeC| or
+% |\citeM| and its ilk will utilize it.
+%    \begin{macrocode}
+\newcommand{\mlastyle@relax}[2][]{\unskip}
+%    \end{macrocode}
+% \end{macro}
+% \subsubsection{MLA Style}
+% \begin{macro}{\citeM}
+% If the \Lopt{mla} or \Lopt{style} options are used, the following is
+% executed.
+%    \begin{macrocode}
+\ifmlastyle@style
+%    \end{macrocode}
+% If the \Lopt{bibstyle} option is set, specify the bibliography style.
+%    \begin{macrocode}
+  \ifmlastyle@bibstyle
+    \bibliographystyle{mlastyle}
+  \fi
+%    \end{macrocode}
+% \end{macro}
+%    \begin{macrocode}
+  \let\cite\citep
+  \let\mlastyle@citequeue\@empty
+  \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}}
+  \newcommand\citeindirectM[2][]{\unskip{} \citep[qtd.\ in][#1]{#2}}
+  \let\citeN\citealp
+  \let\citeC\mlastyle@relax
+%    \end{macrocode}
+% \subsubsection{Plain Style}
+% \begin{macro}{\citeC}
+% This next block is used if the \Lopt{compat} or \Lopt{format} option is
+% set.
+%    \begin{macrocode}
+\else
+%    \end{macrocode}
+% If the \Lopt{bibstyle} option is set, specify the bibliography style.
+%    \begin{macrocode}
+  \ifmlastyle@bibstyle
+    \bibliographystyle{plain}
+  \fi
+  \ifx\@undefined\citet
+    \newcommand{\mlastyle@cite}[2][]{\@tempswafalse\@citex[]{#2}}
+    \newcommand{\citeC}[2][]{~\@tempswafalse\@citex[]{#2}}
+  \else
+    \newcommand{\mlastyle@cite}[2][]{\citep[]{#2}}
+    \def\citeC{ \citep}
+  \fi
+  \let\cite\mlastyle@cite
+  \let\citepage\mlastyle@cite
+  \let\citeindirect\mlastyle@cite
+  \let\citeM\mlastyle@relax
+  \let\citepageM\mlastyle@relax
+  \let\citeindirectM\mlastyle@relax
+\fi
+%    \end{macrocode}
+% \end{macro}
+%
+% ^^A\end{macro}
+% ^^A\end{macro}
+% \end{macro}
+% \end{macro}
 % \subsection{Formatting}
 % Formatting is done if the \Lopt{mla} or \Lopt{format} option is set.
 %    \begin{macrocode}
@@ -659,14 +792,14 @@ Schlegl",
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\slash}
-% No penalty for |\slash|, and plain /'s permit line breaks if necessary.
+% No penalty for |\slash|.
 % ^^A\let\mlastyle@sl@sh=/
 %    \begin{macrocode}
   \def\slash{/\penalty\z@}
-  \def\mlastyle@slash{/\futurelet\mlastyle@slashnext\mlastyle@slashx}
-  \def\mlastyle@slashx{\ifx\mlastyle@slashnext/\else
-    \penalty\exhyphenpenalty\fi}
 %    \end{macrocode}
+% ^^A \def\mlastyle@slash{/\futurelet\mlastyle@slashnext\mlastyle@slashx}
+% ^^A \def\mlastyle@slashx{\ifx\mlastyle@slashnext/\else
+% ^^A  \penalty\exhyphenpenalty\fi}
 % \end{macro}
 % \begin{macro}{\section}
 % \begin{macro}{\subsection}
@@ -715,16 +848,18 @@ Schlegl",
 %    \end{macrocode}
 % \end{environment}
 % \begin{environment}{workscited}
+% \begin{macro}{\bibent}
 % Works cited environment, for compatibility with \package{mla-paper}.
 %    \begin{macrocode}
   \newenvironment{workscited}%
     {\newpage{\centerline{Works Cited}}}{\newpage}
-  \newcommand{\bibent}{\noindent \hangindent\mlastyle@i}
+  \newcommand{\bibent}{\noindent\hangindent\mlastyle@i}
 %    \end{macrocode}
+% \end{macro}
 % \end{environment}
 % \subsubsection{Margins}
 % Top and bottom margins are 1 inch each.  The header is flush with the
-% right margin at .5 inches from the top of the page.
+% right margin, .5 inches from the top of the page.
 % ^^A\addtolength{\headheight}{-1pt}
 % ^^A\setlength{\headheight}{1.4\headheight}% kludge
 %    \begin{macrocode}
@@ -781,12 +916,16 @@ Schlegl",
   \def\@listvi{\leftmargin\leftmarginvi
   \parsep\z@\itemsep\z@\topsep -3\p@\relax}
 %    \end{macrocode}
-% Only one space after colons.
+% \begin{macro}{\nonfrenchspacing}
+% Only one space after colons, unless someone else has already tinkered
+% with its space factor.
 %    \begin{macrocode}
-\ifnum\the\sfcode`\:=2000
-  \sfcode`\:=1999
-\fi
+\let\nonfrenchspacing\mlstyle@intnfs
+\def\nonfrenchspacing{\mlastyle@intnfs
+  \ifnum\the\sfcode`\:=2000\sfcode`\:=1999\fi}
+\ifnum\the\sfcode`\:=2000\sfcode`\:=1999\fi
 %    \end{macrocode}
+% \end{macro}
 % \subsubsection{Header}
 % The last name and page number appear on every page, including the first.
 %    \begin{macrocode}
@@ -826,9 +965,7 @@ Schlegl",
   \fi
 %    \end{macrocode}
 % \subsubsection{Bibliography}
-% \begin{environment}{thebibliography}
-% The definition of |\thebibliography| varies depending on the document
-% class.
+% \textsc{To Do}: Switch to the \package{url} package.
 %    \begin{macrocode}
 \ifx\@undefined\url{
   \catcode`/=13
@@ -836,196 +973,45 @@ Schlegl",
     \let/\slash\mlastyle@url}
     \gdef\mlastyle@url#1{#1\egroup}
 }\fi
-\ifx\@undefined\citet
-  \@ifundefined{chapter}
 %    \end{macrocode}
-% Article class.
-%    \begin{macrocode}
-  { \def\thebibliography#1{\newpage\section*{\refname}
-      \list{\@biblabel{\@arabic\c@enumiv}}%
-        {\settowidth\labelwidth{\@biblabel{#1}}}
-        \leftmargin\labelwidth
-        \advance\leftmargin\labelsep
-        \itemindent-\leftmargin
-        \def\newblock{}
-        \usecounter{enumiv}
-        \sloppy%\sfcode`\.=\@m
-      }}
-%    \end{macrocode}
-% Report/book class.
+% \begin{environment}{thebibliography}
+% The definition of |thebibliography| varies depending on the document
+% class.
 %    \begin{macrocode}
-  { \def\thebibliography#1{\chapter*{\bibname}
+\ifx\@undefined\citet
+    \renewenvironment\thebibliography#1{\clearpage
+      \@ifundefined{chapter}
+        {\section*{\refname}}
+        {\chapter*{\bibname}}
       \list{\@biblabel{\@arabic\c@enumiv}}%
         {\settowidth\labelwidth{\@biblabel{#1}}}
         \leftmargin\labelwidth
         \advance\leftmargin\labelsep
         \itemindent-\leftmargin
-        \def\newblock{}
+        \let\newblock\@empty
+        %\sfcode`\.=\@m
         \usecounter{enumiv}
-        \sloppy%\sfcode`\.=\@m
-      }}
+        \sloppy
+      }
+      {\def\@noitemerr
+        {\@latex@warning{Empty `thebibliography' environment}}%
+      \endlist}
 %    \end{macrocode}
 % \end{environment}
-% \subsubsection{Experimental \package{natbib} Implementation}
+% If the \package{natbib} package is loaded, the following is executed
+% instead.
 %    \begin{macrocode}
 \else
-  \newcommand\bibpreamble{%
-    \@ifundefined{citet}{}%
-    {\bibhang\mlastyle@i\bibsep\z@}}
+  \bibhang\mlastyle@i\bibsep\z@
 \fi
 %    \end{macrocode}
+% ^^A  \newcommand\bibpreamble{%
+% ^^A    \@ifundefined{citet}{}%
+% ^^A    {\bibhang\mlastyle@i\bibsep\z@}}
 %    \begin{macrocode}
 \fi % \ifmlastyle@format
 %    \end{macrocode}
-% \subsection{Style}
-% \begin{macro}{\bibstyle@mlastyle}
-% This first block is the beginnings of an implementation for
-% \package{natbib}.  (Surely there is a better way.)
-%    \begin{macrocode}
-\newcommand{\bibstyle@mlastyle}{%
-  \bibpunct[\mlastyle@space]{\mlastyle@brack(}{\mlastyle@brack)}%
-    {\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
-  \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}}
-  {\gdef\bibname{Works Cited}}}
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\mlastyle@notitle}
-% This hack represents an empty title in the MLA bibliography style.
-%    \begin{macrocode}
-\def\mlastyle@notitle
-  { \ \ \ \ \unskip\unskip\unskip\unskip\unskip}
-\RequirePackage{natbib}
-\newif\ifmlastyle@pages
-\renewcommand\NAT@citetp
-{\@ifnextchar[{\mlastyle@pagestrue\NAT@@citetp}%
-  {\mlastyle@pagesfalse\NAT@@citetp[]}}
-%    \end{macrocode}
-%\end{macro}
-% \begin{macro}{\cite}
-% \begin{macro}{\citealp}
-% ^^A\begin{macro}{\citepage}
-% ^^A\begin{macro}{\citequote}
-% The following macros, combined with \file{mlastyle.bst}, provide
-% for a bibliography in MLA style.  Note that the definition of |\cite|,
-% |\citealp|, etc.\ vary depending on the options passed to
-% \package{mlastyle}.
-%
-% \begin{macro}{\mlastyle@intcite}
-% The original |\cite| is stored
-% in |\mlastyle@intcite|.
-%    \begin{macrocode}
-%\let\mlastyle@intcite\cite
-%    \end{macrocode}
-% \end{macro}
-% \begin{macro}{\mlastyle@relax}
-% This macro does nothing.  Depending on the options, either |\citeC| or
-% |\citeM| and its ilk will utilize it.
-%    \begin{macrocode}
-\newcommand{\mlastyle@relax}[2][]{\unskip}
-%    \end{macrocode}
-% \end{macro}
-% \subsubsection{MLA Style}
-% \begin{macro}{\citeM}
-% If the \Lopt{mla} or \Lopt{style} options are used, the following is
-% executed.
-%    \begin{macrocode}
-\ifmlastyle@style
-%    \end{macrocode}
-% If the \Lopt{bibstyle} option is set, specify the bibliography style.
-%    \begin{macrocode}
-  \ifmlastyle@bibstyle
-    \bibliographystyle{mlastyle}
-  \fi
-%    \end{macrocode}
-% \end{macro}
-%    \begin{macrocode}
-  \let\cite\citep
-  \let\mlastyle@citequeue\empty
-  \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}}
-  \newcommand\citeindirectM[2][]{\unskip{} \citep[qtd.\ in][#1]{#2}}
-  \let\citeN\citealp
-  \let\citeC\mlastyle@relax
-%    \end{macrocode}
-%
-% ^^A% Define the command \workscited{bib}{style}{nocite}
-% ^^A%\newcommand{\workscited}[3]{%
-% ^^A%  \ifx\chapter\@undefined%
-% ^^A%    \addcontentsline{toc}{chapter}{\bfseries\bibname}% report style
-% ^^A%  \else
-% ^^A%    \addcontentsline{toc}{section}{\bfseries\refname}% article style
-% ^^A%  \fi
-% ^^A%  \bibliography{#1}\bibliographystyle{#2}\nocite{#3}}
-% ^^A% \fi
-% ^^A\newcommand{\annote}[1]{\begin{list}{}{%
-% ^^A                \setlength{\labelwidth}{0pt}
-% ^^A                \addtolength{\leftmargin}{\parindent}
-% ^^A                \setlength{\labelsep}{0pt}}%
-% ^^A                \item #1 \end{list}}
-% \subsubsection{Plain Style}
-% \begin{macro}{\citeC}
-% This next block is used if the \Lopt{compat} or \Lopt{format} option is
-% set.
-%    \begin{macrocode}
-\else
-%    \end{macrocode}
-% If the \Lopt{bibstyle} option is set, specify the bibliography style.
-%    \begin{macrocode}
-  \ifmlastyle@bibstyle
-    \bibliographystyle{plain}
-  \fi
-  \ifx\@undefined\citet
-    \newcommand{\mlastyle@cite}[2][]{\@tempswafalse\@citex[]{#2}}
-    \newcommand{\citeC}[2][]{~\@tempswafalse\@citex[]{#2}}
-  \else
-    \newcommand{\mlastyle@cite}[2][]{\citep[]{#2}}
-    \def\citeC{ \citep}
-  \fi
-  \let\cite\mlastyle@cite
-  \let\citepage\mlastyle@cite
-  \let\citeindirect\mlastyle@cite
-  \let\citeM\mlastyle@relax
-  \let\citepageM\mlastyle@relax
-  \let\citeindirectM\mlastyle@relax
-\fi
-%    \end{macrocode}
-% \end{macro}
-%
-% ^^A\end{macro}
-% ^^A\end{macro}
-% \end{macro}
-% \end{macro}
+
 %    \begin{macrocode}
 %</package>
 %    \end{macrocode}