diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/bibtex/bst/natbib/abbrvnat.bst | 6 | ||||
-rw-r--r-- | Master/texmf-dist/bibtex/bst/natbib/plainnat.bst | 6 | ||||
-rw-r--r-- | Master/texmf-dist/bibtex/bst/natbib/unsrtnat.bst | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/natbib/README.v83 (renamed from Master/texmf-dist/doc/latex/natbib/README.v81) | 73 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/natbib/natbib.ltx (renamed from Master/texmf-dist/source/latex/natbib/natbib.drv) | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/natbib/natbib.pdf | bin | 168252 -> 187005 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/natbib/natnotes.pdf | bin | 85898 -> 88223 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/natbib/natnotes.tex | 73 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/natbib/natbib.dtx | 1997 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/natbib/natbib.ins | 8 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/natbib/natbib.sty | 984 |
11 files changed, 2367 insertions, 793 deletions
diff --git a/Master/texmf-dist/bibtex/bst/natbib/abbrvnat.bst b/Master/texmf-dist/bibtex/bst/natbib/abbrvnat.bst index b9c270d132f..6109cb74813 100644 --- a/Master/texmf-dist/bibtex/bst/natbib/abbrvnat.bst +++ b/Master/texmf-dist/bibtex/bst/natbib/abbrvnat.bst @@ -14,7 +14,7 @@ %% version 1 of the License, or any later version. %% % Version and source file information: - % \ProvidesFile{natbst.mbs}[2007/02/19 1.92 (PWD)] + % \ProvidesFile{natbst.mbs}[2007/11/26 1.93 (PWD)] % % BibTeX `plainnat' family % version 0.99b for BibTeX versions 0.99a or later, @@ -1331,6 +1331,10 @@ FUNCTION {presort} if$ " " * + year field.or.null sortify + * + " " + * cite$ * #1 entry.max$ substring$ diff --git a/Master/texmf-dist/bibtex/bst/natbib/plainnat.bst b/Master/texmf-dist/bibtex/bst/natbib/plainnat.bst index f842e75686f..4746cf13f70 100644 --- a/Master/texmf-dist/bibtex/bst/natbib/plainnat.bst +++ b/Master/texmf-dist/bibtex/bst/natbib/plainnat.bst @@ -14,7 +14,7 @@ %% version 1 of the License, or any later version. %% % Version and source file information: - % \ProvidesFile{natbst.mbs}[2007/02/19 1.92 (PWD)] + % \ProvidesFile{natbst.mbs}[2007/11/26 1.93 (PWD)] % % BibTeX `plainnat' family % version 0.99b for BibTeX versions 0.99a or later, @@ -1331,6 +1331,10 @@ FUNCTION {presort} if$ " " * + year field.or.null sortify + * + " " + * cite$ * #1 entry.max$ substring$ diff --git a/Master/texmf-dist/bibtex/bst/natbib/unsrtnat.bst b/Master/texmf-dist/bibtex/bst/natbib/unsrtnat.bst index f625b5bdf8a..5d82d41fc46 100644 --- a/Master/texmf-dist/bibtex/bst/natbib/unsrtnat.bst +++ b/Master/texmf-dist/bibtex/bst/natbib/unsrtnat.bst @@ -14,7 +14,7 @@ %% version 1 of the License, or any later version. %% % Version and source file information: - % \ProvidesFile{natbst.mbs}[2007/02/19 1.92 (PWD)] + % \ProvidesFile{natbst.mbs}[2007/11/26 1.93 (PWD)] % % BibTeX `plainnat' family % version 0.99b for BibTeX versions 0.99a or later, diff --git a/Master/texmf-dist/doc/latex/natbib/README.v81 b/Master/texmf-dist/doc/latex/natbib/README.v83 index f1269741554..22b2ef9b2b4 100644 --- a/Master/texmf-dist/doc/latex/natbib/README.v81 +++ b/Master/texmf-dist/doc/latex/natbib/README.v83 @@ -1,10 +1,13 @@ NATBIB Package -Current Version: 8.1 from 2007/10/30 +Current Version: 8.3 from 2008/12/08 See list of changes below This is the natbib package for handling both author-year and numerical -BibTeX styles. It contains the following files: +BibTeX styles. + +Manifest:- The natbib package contains the following files: +~~~~~~~~~~ natbib.dtx -- Documented source file that may be LaTeXed to get the detailed description and/or coding documentation; needs ltxdoc class distributed with LaTeX2e. @@ -29,20 +32,19 @@ BibTeX styles. It contains the following files: bibentry.ins -- The installation file for bibentry. Just TeX or LaTeX it. -Installation:- Simply run TeX or LaTeX on natbib.ins, which extracts -~~~~~~~~~~~~~~ natbib.sty from the documented source natbib.dtx. You - may first edit natbib.ins if you want natbib209.sty and/or - natbib.drv, the configurable documentation driver. If - natbib.ins has been lost, it may be regenerated by running - LaTeX on natbib.dtx. - +Generation:- Simply run TeX or LaTeX on natbib.ins, which extracts +~~~~~~~~~~~~ natbib.sty from the documented source natbib.dtx. You + may first edit natbib.ins if you want natbib.drv, the + configurable documentation driver. If natbib.ins has been + lost, it may be regenerated by running LaTeX on natbib.dtx. + Natbib.ins also extracts the reference sheet source file, natnotes.tex. For the bibentry package, TeX or LaTeX bibentry.ins, which extracts bibentry.sty. -Documentation:- Run LaTeX on natbib.dtx or natbib.drv. The latter may be +Documentation:- Run LaTeX on natbib.dtx or natbib.ltx. The latter may be ~~~~~~~~~~~~~~~ edited as needed to conform to local requirements (paper size, duplex or not, with or without entire coding). Alternatively, a ltxdoc.cfg file can contain local @@ -53,6 +55,7 @@ Documentation:- Run LaTeX on natbib.dtx or natbib.drv. The latter may be Reference Sheet:- Run LaTeX on natnotes.tex (extracted from natbib.dtx when ~~~~~~~~~~~~~~~~~ natbib.dtx was processed). This is a 5 page summary of the main natbib features. + The package will accept BibTeX output in the forms: \bibitem{key} (standard numerical format) @@ -121,6 +124,54 @@ For full details, print out the documentation in natbib.dtx by LaTeXing it. ------------------------------------------------------------------------- List of changes + v8.3 Incorporate the new features from Arthur Ogawa (non-released 8.2) so that they + do not conflict with regular natbib usage. + Improve compatibility with babel, in particular so that it works right with + active characters in the citation keys + Fix bug with multiple superscripted citations, to get spacings, comma right + Correct problem with chapterbib package + Adjust location of optional notes so they are always inside the parentheses + (as stated in the documentation) + + v8.2 (by Arthur Ogawa) + (This version was never publically released; these features first appear in V8.3) + + Introduce package option [merge], providing the functionality of Thorsten Ohl's + mcite package. See the user documentation for details. + + If an @Article reference is merged back with another, there exists the possibility + of eliding (typical in APS and AIP journals): if the author matches, then it is + elided, if the author matches and the journal does, too, then both are elided. + If the author does not match, but the journal matches, the latter is replaced + by \textit{ibid.}. It is possible to modify these eliding rules, customizing natbib + to your requirements. + + It is possible to change the merge, sort, and compress options even after the + package loads, and even after \begin{document}. + + When sorting citations, the sort is now stable. + + It is now possible to automatically add punctuation between citations, like the word `and'. + + Robustness has been improved when first adopting the natbib package and when + terminating its use (removing the \usepackage{natbib} statement). + + Compatability with other packages has been improved, particularly any that + want to know if \chapter has been defined. + + The \citation command is written to the .aux file with its arguments in the + same order as in the user's \cite command, that is, before sorting is done. + The old way had the effect of resisting the user's efforts to change the order + of citations if sorting was in effect. + + The cite key may have a star and two optional arguments preceding it, as in: + \cite{*[<pre-text>][<post-text>]key}, where <pre-text> is prepended to the reference, + producing something like ``See, e.g., Bumstead, D. (1945)...'', and where <post-text> + is appended to the reference, producing something like, + ``... p. 42, and references therein.'' The star (*) signifies that merging is to be done. + + Various implementation changes; see the package documentation for details. + v8.1 Replace some \edef with \protected@edef, requested by users of preview package v8.0 Add \setcitestyle to simplify changing citation punctuation; is to replace @@ -440,7 +491,7 @@ Changes from previous (4.x) versions: Under LaTeX2e, punctuation can be selected with options in \usepackage ------------------------------------------------------------------------- -2006 Jan 12 +2009 Jan 31 Patrick W. Daly Max-Planck-Institut f\"ur Sonnensystemforschung D-37191 Katlenburg-Lindau, Germany diff --git a/Master/texmf-dist/source/latex/natbib/natbib.drv b/Master/texmf-dist/doc/latex/natbib/natbib.ltx index 62be6e3fb69..8e29bbeae66 100644 --- a/Master/texmf-dist/source/latex/natbib/natbib.drv +++ b/Master/texmf-dist/doc/latex/natbib/natbib.ltx @@ -1,5 +1,5 @@ %% -%% This is file `natbib.drv', +%% This is file `natbib.ltx', %% generated with the docstrip utility. %% %% The original source files were: @@ -11,15 +11,15 @@ %% %% Make changes to it as needed. (Never change the file natbib.dtx!) %% ============================================ -%% Copyright 1993-2007 Patrick W Daly +%% Copyright 1993-2009 Patrick W Daly %% Max-Planck-Institut f\"ur Sonnensystemforschung %% Max-Planck-Str. 2 %% D-37191 Katlenburg-Lindau %% Germany %% E-mail: daly@mps.mpg.de \NeedsTeXFormat{LaTeX2e} -\ProvidesFile{natbib.drv} - [2007/10/30 8.1 (PWD)] +\ProvidesFile{natbib.ltx} + [2009/02/02 8.3 (PWD, AO)] \documentclass{ltxdoc} %\documentclass[twoside]{ltxdoc} %\documentclass[a4paper]{ltxdoc} @@ -46,7 +46,8 @@ \begin{document} \DocInput{natbib.dtx} \end{document} + %% %% End of documentation driver file. %% -%% End of file `natbib.drv'. +%% End of file `natbib.ltx'. diff --git a/Master/texmf-dist/doc/latex/natbib/natbib.pdf b/Master/texmf-dist/doc/latex/natbib/natbib.pdf Binary files differindex 55d8b5fbe8c..6a9a4d1a353 100644 --- a/Master/texmf-dist/doc/latex/natbib/natbib.pdf +++ b/Master/texmf-dist/doc/latex/natbib/natbib.pdf diff --git a/Master/texmf-dist/doc/latex/natbib/natnotes.pdf b/Master/texmf-dist/doc/latex/natbib/natnotes.pdf Binary files differindex 19da8e7caf3..c9bb7426821 100644 --- a/Master/texmf-dist/doc/latex/natbib/natnotes.pdf +++ b/Master/texmf-dist/doc/latex/natbib/natnotes.pdf diff --git a/Master/texmf-dist/doc/latex/natbib/natnotes.tex b/Master/texmf-dist/doc/latex/natbib/natnotes.tex index 4d5ccedb3cb..4a3a6addd02 100644 --- a/Master/texmf-dist/doc/latex/natbib/natnotes.tex +++ b/Master/texmf-dist/doc/latex/natbib/natnotes.tex @@ -1,5 +1,5 @@ %% -%% This is file `natnotes', +%% This is file `natnotes.tex', %% generated with the docstrip utility. %% %% The original source files were: @@ -21,7 +21,7 @@ %% %% For more details, LaTeX the source natbib.dtx. %% ============================================== -%% Copyright 1993-2007 Patrick W Daly +%% Copyright 1993-2009 Patrick W Daly %% Max-Planck-Institut f\"ur Sonnensystemforschung %% Max-Planck-Str. 2 %% D-37191 Katlenburg-Lindau @@ -31,7 +31,7 @@ \def\DescribesFile#1 [#2 #3 #4] {\def\filename{#1}\def\filedate{#2}\def\fileversion{#3}} \DescribesFile{natbib} - [2007/10/30 8.1 (PWD)] + [2009/02/02 8.3 (PWD, AO)] \documentclass{article} \setlength{\parindent}{0pt} @@ -205,14 +205,26 @@ hyperlinks. \head{Selecting citation style and punctuation} Use the command |\setcitestyle| with a list of comma-separated keywords (without spaces) as argument. -\begin{quote} - Citation mode: |authoryear| or |numbers| or |super|\\ - Braces: |round| or |square| or |open={|\emph{char}|},close={|\emph{char}|}|\\ - Between citations: |semicolon| or |comma| or |citesep={|\emph{char}|}|\\ - Between author and year: |aysep={|\emph{char}|}|\\ - Between years with common author: |yysep={|\emph{char}|}|\\ +\begin{itemize} +\item + Citation mode: |authoryear| or |numbers| or |super| + %^^A \ifNAT@numbers \ifNAT@super +\item + Braces: |round| or |square| or |open={|\emph{char}|},close={|\emph{char}|}| + %^^A \NAT@open \NAT@close +\item + Between citations: |semicolon| or |comma| or |citesep={|\emph{char}|}| + %^^A \NAT@sep +\item + Between author and year: |aysep={|\emph{char}|}| + %^^A \NAT@aysep +\item + Between years with common author: |yysep={|\emph{char}|}| + %^^A \NAT@yrsep +\item Text before post-note: |notesep={|\emph{text}|}| -\end{quote} + %^^A \NAT@cmt +\end{itemize} Defaults are |authoryear|, |round|, |comma|, |aysep={;}|, |yysep={,}|, |notesep={, }| @@ -233,13 +245,13 @@ into (Jones et al. 1990; and references therein). Redefine |\bibsection| to the desired sectioning command for introducing the list of references. This is normally |\section*| or |\chapter*|. -Define |\bibpreamble| to be any text that is to be printed after the heading but +Redefine |\bibpreamble| to be any text that is to be printed after the heading but before the actual list of references. -Define |\bibfont| to be a font declaration, e.g.\ |\small| to apply to +Redefine |\bibfont| to be a font declaration, e.g.\ |\small| to apply to the list of references. -Define |\citenumfont| to be a font declaration or command like |\itshape| +Redefine |\citenumfont| to be a font declaration or command like |\itshape| or |\textit|. Redefine |\bibnumfmt| as a command with an argument to format the numbers in @@ -292,6 +304,31 @@ options \texttt{sort}, \texttt{compress}, or \texttt{sort\&compress}. These also work with author--year citations, making multiple citations appear in their order in the reference list. + +\head{Merged Numerical References} +Do not use the \texttt{mcite} package with \thestyle; rather use the package option \texttt{merge}. + + +With this option in effect, citation keys within a multiple |\citep| command +may contain a leading * that causes them to be merged in the bibliography +together with the previous citation as a single entry with a single reference +number. For example, |\citep{feynmann,*salam,*epr}| produces a single number, +and all three references are listed in the bibliography under one entry with +that number. + +The \texttt{elide} option also activates the merging features, but also sees +to it that common parts of the merged references (e.g., authors) are not +repeated but are written only once in the single bibliography entry. + +The \texttt{mcite} option turns off the merging and eliding features, but +allows the special syntax (the * and optional inserted texts) to be ignored. + +These functions are available only to numerical-mode citations, and only when +used parenthetically, similar to the restrictions on \texttt{sort} and +\texttt{compress}. + +They also require special \texttt{.bst} files, as provided for example by the +American Physical Society for their REV\TeX\ class. \head{Long author list on first citation} Use option \texttt{longnamesfirst} to have first citation automatically give the full list of authors. @@ -333,11 +370,17 @@ is read in after the main package file. |\chapter| command; to be used with the \texttt{chapterbib} package; \item[\ttfamily nonamebreak] keeps all the authors' names in a citation on one line; causes overfull hboxes but helps with some \texttt{hyperref} - problems. + problems; +\item[\ttfamily merge] to allow the * prefix to the citation key, + and to merge such a citation's reference with that of the previous + citation; +\item[\ttfamily elide] to elide common elements of merged references, like + the authors or year; +\item[\ttfamily mcite] to recognize (and ignore) the merging syntax. \end{description} \end{document} %% %% End of Reference Sheet file %% %% -%% End of file `natnotes'. +%% End of file `natnotes.tex'. diff --git a/Master/texmf-dist/source/latex/natbib/natbib.dtx b/Master/texmf-dist/source/latex/natbib/natbib.dtx index 794bb080155..3fd60e9fee0 100644 --- a/Master/texmf-dist/source/latex/natbib/natbib.dtx +++ b/Master/texmf-dist/source/latex/natbib/natbib.dtx @@ -5,7 +5,7 @@ {NATBIB.DTX} %======================================================================== %</dtx> -%% Copyright 1993-2007 Patrick W Daly +%% Copyright 1993-2009 Patrick W Daly %% Max-Planck-Institut f\"ur Sonnensystemforschung %% Max-Planck-Str. 2 %% D-37191 Katlenburg-Lindau @@ -26,7 +26,7 @@ % LaTeX this file: creates docstrip installation file natbib.ins % AND the documentation % (La)TeX natbib.ins: creates package file natbib.sty -% and optionally documentation driver natbib.drv +% and optionally documentation driver natbib.ltx % (natbib.ins may be edited as needed) % Docstrip options available: % package - to produce a package .sty file @@ -50,12 +50,12 @@ % % *** Identify the driver file:- %<driver>\NeedsTeXFormat{LaTeX2e} -%<driver>\ProvidesFile{natbib.drv} +%<driver>\ProvidesFile{natbib.ltx} % % *** The DATE, VERSION, and other INFO %\fi %\ProvidesFile{natbib} - [2007/10/30 8.1 (PWD)] + [2009/02/02 8.3 (PWD, AO)] % \changes{4.0}{1993 Aug 19}{First documented release} % \changes{4.1}{1993 Oct 4}{Simplification of \cs{@citeapalk}} % \changes{4.1a}{1993 Oct 14}{Add \texttt{rev} option for reversed comments @@ -174,8 +174,49 @@ % \changes{8.0}{2007 Feb 5}{Remove 2.09 support} % \changes{8.0}{2007 Feb 5}{Remove subpackage option (and agu, egs options)} % \changes{8.1}{2007 Oct 30}{Replace some \cs{edef}s with \cs{protected@edef}} -% -% \CheckSum{2381} +% \changes{8.2}{2008 Jan 10}{(AO)Introduce, for \texttt{merge} package option, +% \cs{NAT@bibitem@first@sw} and \cs{NAT@bibitem@label@sw}} +% \changes{8.2}{2008 Jan 10}{(AO) The sort algorithm had not been stable; fixed.}% +% \changes{8.2}{2008 Jan 10}{(AO) Various changes to \texttt{NAT@sort@cites} and friends}% +% \changes{8.2}{2008 Jun 26}{(AO) Employ \cs{NAT@ifcat@num} to make the test on \cs{NAT@num}}% +% \changes{8.2}{2008 Jun 26}{(AO) Use \cs{NAT@space}, \cs{NAT@spacechar}, and \cs{NAT@penalty} +% instead of explicit space and primitive penalty in \cs{NAT@idxtxt}, +% \cs{NAT@cite}, \cs{NAT@citenum}, \cs{NAT@citesuper}.}% +% \changes{8.2}{2008 Jun 28}{(AO) Introduce \cs{NAT@ifcat@num}, ensuring that the +% \cs{catcode} of the underscore is 8 at the time; +% use for tests on \cs{NAT@num} and \cs{NAT@last@num}.}% +% \changes{8.2}{2008 Jul 01}{(AO) Allow graceful transition away from the use of \texttt{natbib}}% +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@}: +% allow for tighter \cs{ifnum} comparisons.}% +% \changes{8.2}{2008 Jul 01}{(AO) Give \cs{NAT@split} a good argument, +% even when \cs{NAT@temp} is poorly constructed.}% +% \changes{8.2}{2008 Jul 01}{(AO) Provide a layer of abstraction to assignments +% to \cs{@citea}, using \cs{NAT@def@citea} and \cs{NAT@reset@citea}.}% +% \changes{8.2}{2008 Jul 01}{(AO) With our abstraction of \cs{@citea}; +% we use wrappers \cs{NAT@def@citea@box} and \cs{NAT@hyper@citea}. Also \cs{NAT@penalty} in place of an explicit \cs{penalty}.}% +% \changes{8.2}{2008 Jul 01}{(AO) Use \cs{NAT@hyper@} and \cs{NAT@hyper@citea} +% to wrap up the hyperlink calls in \cs{NAT@citexnum}, \cs{NAT@citex}, .}% +% \changes{8.2}{2008 Jul 02}{(AO) Add \cs{@ifxundefined}, a tool for testing a \cs{TeX} macro, +% and \cs{@ifnum}, a tool for testing numbers, like \cs{ifnum}.}% +% \changes{8.2}{2008 Jul 02}{(AO) Employ \cs{@ifxundefined}, instead of \cs{@ifundefined}, +% for use on \cs{@cprwrite}, \cs{@indexfile}, \cs{bbl@redefine}, \cs{chapter}, +% \cs{NAT@sectionbib}, and \cs{bib@heading}: the \cs{csname} being tested ought not to be altered as a side effect.}% +% \changes{8.2}{2008 Jul 02}{(AO) The value of \cs{NAT@sort} and \cs{NAT@cmprs} +% will be \cs{z@} or \cs{@ne}: something created by \cs{chardef}. This works better in \cs{ifnum} tests.}% +% \changes{8.2}{2008 Jul 12}{(AO) Do not write .aux file entries in \cs{NAT@citexnum} +% or \cs{NAT@citex}; do this in \cs{NAT@sort@cites} where the keys will be in the user's order.} +% \changes{8.2}{2008 Jul 13}{(AO) Allow optional arguments preceding cite key.} +% \changes{8.2}{2008 Jul 13}{(AO) Commented-out code has been made into a comment.} +% \changes{8.2}{2008 Jul 13}{(AO) Protect against case where \cs{NAT@num} is +% defined to be the same as \cs{@empty} (malformed \texttt{.aux} file).} +% \changes{8.3}{2008 Aug 28}{Refine the compatibility with babel} +% \changes{8.3}{2008 Sep 23}{Fix problem with spacing and raised commas for multiple superscripts} +% \changes{8.3}{2008 Nov 5}{Repair a number of bugs from AO's coding} +% \changes{8.3}{2008 Dec 8}{Put all comments inside braces with \cs{citet}, +% even for numerical (previously only for author--year)} +% \changes{8.3}{2009 Feb 2}{Include AO's last delta corrections} +% +% \CheckSum{2848} % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z @@ -201,7 +242,7 @@ %^^A ============================================= \begin{filecontents*}{natbib.ins} % File: natbib.ins -% Copyright 2006 Patrick W. Daly +% Copyright 2009 Patrick W. Daly % % This is the natbib installation file for extracting package and driver % files from the original source file. Simply process it under @@ -275,16 +316,16 @@ End of documentation driver file. \askforoverwritefalse \generate{\file{natbib.sty}{\from{natbib.dtx}{package,all}} - \file{natnotes}{\usepreamble\refsheet\usepostamble\refsheetq + \file{natnotes.tex}{\usepreamble\refsheet\usepostamble\refsheetq \from{natbib.dtx}{notes}} - \file{natbib.drv}{\usepreamble\driver\usepostamble\driverq + \file{natbib.ltx}{\usepreamble\driver\usepostamble\driverq \from{natbib.dtx}{driver}} } \obeyspaces \Msg{*********************************************}% \Msg{* For documentation, process natbib.dtx *}% -\Msg{* or the driver file natbib.drv *}% +\Msg{* or the driver file natbib.ltx *}% \Msg{* For reference sheet, process natnotes.tex *} \Msg{*********************************************} \end{filecontents*} @@ -403,8 +444,8 @@ End of documentation driver file. % \DoNotIndex{\@sort@celt,\@tempcnta,\@tempcntb,\delimiter,\endgroup} % \DoNotIndex{\ifcat,\m@ne,\number,\kern,\protected@edef} % \DoNotIndex{\@markboth,\@mkboth,\nobreak,\SK@,\SK@@citex} -% \DoNotIndex{\SK@@label,\SK@@ref,SK@def,\SK@lbibitem,\bbl@redefine} -% \DoNotIndex{\@safe@activesfalse,\@save@activestrue,\active@prefix} +% \DoNotIndex{\SK@@label,\SK@@ref,SK@def,\SK@lbibitem} +% \DoNotIndex{\@nameuse,\@extra@b@citeb,\@tempb,\@tempc} % % \setcounter{IndexColumns}{2} % \setlength{\IndexMin}{10cm} @@ -417,11 +458,12 @@ End of documentation driver file. % \title{{\bfseries Natural Sciences Citations and References}\\ % (Author--Year and Numerical Schemes)} % -% \author{Patrick W. Daly} +% \author{Patrick W. Daly\thanks{% +% The code for merged numerical bibliography entries, emulating the \texttt{mcite} package, +% has been commissioned by the American Physical Society and provided by Arthur Ogawa}} % % \date{This paper describes package \texttt{\filename}\\ -% version \fileversion{} from \filedate. -% } +% version \fileversion{} from \filedate.} % % \maketitle % @@ -479,9 +521,10 @@ with those for \texttt{harvard}, \texttt{apalike}, \texttt{chicago}, % % It is compatible with the packages: \texttt{babel}, \texttt{index}, \texttt{citeref}, % \texttt{showkeys}, \texttt{chapterbib}, \texttt{hyperref}, \texttt{koma} and -% with the classes \texttt{amsbook} and \texttt{amsart}. It can also emulate the -% sorting and compressing functions of the \texttt{cite} package (with which it -% is otherwise incompatible). +% with the classes \texttt{amsbook} and \texttt{amsart}. +% It can also emulate the sorting and compressing functions of the \texttt{cite} package +% as well as the multiple citation (and merging) functions of Thorsten Ohl's \texttt{mcite} package. +% (The \thestyle{} package, however, is not compatible with either \texttt{cite} or \texttt{mcite} themselves.) % % Note that the \texttt{citeref} package (for adding citation page numbers in the % bibliography) must be loaded after \thestyle. (The \texttt{hyperref} package with @@ -1040,14 +1083,32 @@ hyperlinks. Use the command |\setcitestyle| with a list of comma-separated keywords (without spaces) as argument. % \fi -\begin{quote} - Citation mode: |authoryear| or |numbers| or |super|\\ - Braces: |round| or |square| or |open={|\emph{char}|},close={|\emph{char}|}|\\ - Between citations: |semicolon| or |comma| or |citesep={|\emph{char}|}|\\ - Between author and year: |aysep={|\emph{char}|}|\\ - Between years with common author: |yysep={|\emph{char}|}|\\ +\begin{itemize} +\item + Citation mode: |authoryear| or |numbers| or |super| +% (corresponds to fourth argument of |\bibpunct|). + %^^A \ifNAT@numbers \ifNAT@super +\item + Braces: |round| or |square| or |open={|\emph{char}|},close={|\emph{char}|}| +% (corresponds to first and second arguments of |\bibpunct|). + %^^A \NAT@open \NAT@close +\item + Between citations: |semicolon| or |comma| or |citesep={|\emph{char}|}| +% (corresponds to third argument of |\bibpunct|). + %^^A \NAT@sep +\item + Between author and year: |aysep={|\emph{char}|}| +% (corresponds to fifth argument of |\bibpunct|). + %^^A \NAT@aysep +\item + Between years with common author: |yysep={|\emph{char}|}| +% (corresponds to sixth argument of |\bibpunct|). + %^^A \NAT@yrsep +\item Text before post-note: |notesep={|\emph{text}|}| -\end{quote} +% (corresponds to optional argument of |\bibpunct|). + %^^A \NAT@cmt +\end{itemize} Defaults are |authoryear|, |round|, |comma|, |aysep={;}|, |yysep={,}|, |notesep={, }| @@ -1084,8 +1145,8 @@ into (Jones et al. 1990; and references therein). % \end{itemize} % % \DescribeMacro{\bibpunct} -% The older command for setting the citation style is |\bibpunct| which -% takes one optional and 6 mandatory arguments: +% The older command for setting the citation style is |\bibpunct|, which +% takes one optional and six required arguments: % \begin{enumerate} % \item the opening bracket symbol, default = ( % \item the closing bracket symbol, default = ) @@ -1143,7 +1204,7 @@ into (Jones et al. 1990; and references therein). % This means that a citation style can be % directly associated with a \texttt{.bst} file. Such implicit styles are % immediately overwritten by any explicit style specifications, such as package -% options or |\setcitestyle|, |\bibpunct|, |\citestyle| commands. +% options, or by |\setcitestyle|, |\bibpunct|, or |\citestyle| commands. % % Predefined citation styles are contained within the \thestyle\ code for the % following bibliography styles: @@ -1215,26 +1276,26 @@ the list of references. This is normally |\section*| or |\chapter*|. % % \DescribeMacro{\bibpreamble} % A preamble appearing after the |\bibsection| heading may be inserted before -% the actual list of references by defining |\bibpreamble|. This will appear in +% the actual list of references by redefining |\bibpreamble|. This will appear in % the normal text font unless it contains font declarations. The % |\bibfont| applies to the list of references, not to this preamble. % % \iffalse -Define |\bibpreamble| to be any text that is to be printed after the heading but +Redefine |\bibpreamble| to be any text that is to be printed after the heading but before the actual list of references. % \fi % % \DescribeMacro{\bibfont} % The list of references is normally printed in the same font size and -% style as the main body. However, it is possible to define |\bibfont| +% style as the main body. However, it is possible to redefine |\bibfont| % to be font commands that are in effect within the \texttt{thebibliography} % environment after any preamble. For example, % \begin{quote} -% |\newcommand{\bibfont}{\small}| +% |\renewcommand{\bibfont}{\small}| % \end{quote} % \iffalse -Define |\bibfont| to be a font declaration, e.g.\ |\small| to apply to +Redefine |\bibfont| to be a font declaration, e.g.\ |\small| to apply to the list of references. % \fi @@ -1244,12 +1305,12 @@ the list of references. % to be a font declaration like |\itshape| or even a command taking arguments % like |\textit|. % \begin{quote} -% |\newcommand{\citenumfont}[1]{\textit{#1}}| +% |\renewcommand{\citenumfont}[1]{\textit{#1}}| % \end{quote} % The above is better than |\itshape| since it automatically adds italic % correction. % \iffalse -Define |\citenumfont| to be a font declaration or command like |\itshape| +Redefine |\citenumfont| to be a font declaration or command like |\itshape| or |\textit|. % \fi @@ -1347,7 +1408,7 @@ entries will no longer be made. % % \subsection{Hyper\TeX\ Compatibility} % The \thestyle\ package is compatible with the \texttt{hyperref} -% package of Sebastian Rahtz +% package of Sebastian Rahtz and Heiko Oberdiek. % , for use with % \LaTeX\ $\rightarrow$ HTML conversions, pdf\TeX, \texttt{pdfmark}. % The compatibility is of a mutual nature: both packages contain @@ -1479,6 +1540,75 @@ in their order in the reference list. %</notes> % \fi % +% \subsection{Merged Numerical References} +% \label{sec:merge} + +% \iffalse +%<*notes> +\head{Merged Numerical References} +Do not use the \texttt{mcite} package with \thestyle; rather use the package option \texttt{merge}. + +%</notes> +% \fi +% \begin{quote} +% \textbf{Note:} the |merge| coding was contributed by +% Arthur Ogawa for the American Physical Society. +% \end{quote} +% +% Thorsten Ohl's \texttt{mcite} package cannot be used together with +% \thestyle. Instead, one must invoke the package option +% \texttt{merge} with the |\usepackage| statement. +% +% \iffalse +%<*notes> +% \fi + +With this option in effect, citation keys within a multiple |\citep| command +may contain a leading * that causes them to be merged in the bibliography +together with the previous citation as a single entry with a single reference +number. For example, |\citep{feynmann,*salam,*epr}| produces a single number, +and all three references are listed in the bibliography under one entry with +that number. +% +% Certain restrictions of Thorsten Ohl's \texttt{mcite} package are lifted: a * +% prefix can be used with any citation key, and Ohl's restrictions on syntax do +% not apply. +% +% An additional feature allows text to be inserted inside the bibliography entry: +% within the argument of \verb+\citep+, a cite key may be preceded by two optional arguements, e.g., +% \verb+\citep{[+\emph{pre}\verb+][+\emph{post}\verb+]+\emph{key}\verb+}+, +% where \emph{pre} represents text to be prepended to the reference (\verb+\bibitem+ content), +% with \emph{post} appended thereto. +% +% Thus it is possible for the user to mark up the document: +% \begin{verbatim} +% text \citep{*[{See, e.g., }][ for a simpler explanation]ablebaker} +% \end{verbatim} +% The above example illustrates the use of the star-form and both optional arguments. +% +% \medskip\noindent +% \textbf{Caution:} Because the comma (,) character is part of the syntax of \verb+\citep+, +% and because the bracket delimiters ([]) are mere text characters and not true delimiters (like the braces), +% you must enclose the optional argument in braces (\verb+{}+) if a comma is present in the +% argument (that goes for brackets, too, of course). + +The \texttt{elide} option also activates the merging features, but also sees +to it that common parts of the merged references (e.g., authors) are not +repeated but are written only once in the single bibliography entry. + +The \texttt{mcite} option turns off the merging and eliding features, but +allows the special syntax (the * and optional inserted texts) to be ignored. + +These functions are available only to numerical-mode citations, and only when +used parenthetically, similar to the restrictions on \texttt{sort} and +\texttt{compress}. + +They also require special \texttt{.bst} files, as provided for example by the +American Physical Society for their REV\TeX\ class. +% \iffalse +%</notes> +% \fi +% % \subsection{Long Author List on First Citation}\label{sec:long} % % A feature that has often been requested by otherwise happy users of @@ -1616,7 +1746,13 @@ is read in after the main package file. |\chapter| command; to be used with the \texttt{chapterbib} package; \item[\ttfamily nonamebreak] keeps all the authors' names in a citation on one line; causes overfull hboxes but helps with some \texttt{hyperref} - problems. + problems; +\item[\ttfamily merge] to allow the * prefix to the citation key, + and to merge such a citation's reference with that of the previous + citation; +\item[\ttfamily elide] to elide common elements of merged references, like + the authors or year; +\item[\ttfamily mcite] to recognize (and ignore) the merging syntax. \end{description} % The options \texttt{curly} and \texttt{angle} are not really serious; I only % added them because that completes the normal list of bracket types. The only @@ -1766,6 +1902,10 @@ is read in after the main package file. % compress - compresses without sorting % longnamesfirst - makes first citation full author list % sectionbib - puts bibliography in a \section* instead of \chapter* + % merge - allows the citation key to have a * prefix, + % signifying to merge its reference with that of the previous citation. + % elide - if references are merged, repeated portions of later ones may be removed. + % mcite - recognizes and ignores the * prefix for merging. % Punctuation so selected dominates over any predefined ones. % Package options are called as, e.g. % \usepackage[square,comma]{natbib} @@ -1807,7 +1947,7 @@ is read in after the main package file. % \item[\ttfamily notes] extracts a summary of usage to be used as a % reference sheet; the resulting file is to be \LaTeX{}ed; % -% \item[\ttfamily driver] to produce a driver \texttt{.drv} file that will +% \item[\ttfamily driver] to produce a driver \texttt{.ltx} file that will % print out the documentation when \LaTeX'd. This file can be modified % to produce various alternatives (page size, fonts, manual only, or with % annotated code). The \thestyle\texttt{.dtx} file is itself such a driver @@ -1981,6 +2121,9 @@ is read in after the main package file. % It is nested between |%<*package>| and |%</package>|, which % are indicators to \texttt{docstrip} that this coding belongs to the package % file. +% \begin{macrocode} +%<*package> +% \end{macrocode} % % With \LaTeX\ release from \texttt{1995/12/01}, |\cite| is made robust, % something that I have adopted as well. @@ -1994,17 +2137,56 @@ is read in after the main package file. % relying on the kernel coding, I make \thestyle\ more % self-reliant. % +% \subsection{Prerequisites} +% +% \begin{macro}{\@ifxundefined} +% \begin{macro}{\@ifnum} +% \changes{8.2}{2008 Jul 02}{(AO) Add \cs{@ifxundefined}, a tool for testing a +% \cs{TeX} macro, and \cs{@ifnum}, a tool for testing numbers, like \cs{ifnum}.} +% The test |\@ifxundefined| is similar syntactically to |\@ifundefined|, but +% its first argument is a control sequence name. +% +% A singular disadvantage of |\@ifundefined| is its side effect of +% changing the state of the effective control sequence name, if undefined, to |\relax|. +% In the usual usage of |\@ifundefined|, this does not have serious consequences, +% but it can, and |\@ifxundefined| avoids these. +% +% We also provide |\@ifnum|, a vehicle for |\ifnum| tests, but using the same +% Boolean algebra as, e.g., |\@ifundefined|, with its attendant advantages. +% \begin{macrocode} +\providecommand\@ifxundefined[1]{% + \ifx#1\@undefined\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +}% +\providecommand\@ifnum[1]{% + \ifnum#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +}% +\providecommand\@ifx[1]{% + \ifx#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +}% +\providecommand\appdef[2]{% + \toks@\expandafter{#1}\@temptokena{#2}% + \edef#1{\the\toks@\the\@temptokena}% +}% +% \end{macrocode} +%\end{macro} +%\end{macro} +% % \subsection{Test for Specific Journals} % This package should not be loaded with the specific journal packages that % already include it; it is superfluous and can lead to contradictions. % \begin{macrocode} -%<*package> \@ifclassloaded{agu2001}{\PackageError{natbib} {The agu2001 class already includes natbib coding,\MessageBreak so you should not add it explicitly} {Type <Return> for now, but then later remove\MessageBreak the command \protect\usepackage{natbib} from the document} \endinput}{} +\@ifclassloaded{agutex}{\PackageError{natbib} + {The AGUTeX class already includes natbib coding,\MessageBreak + so you should not add it explicitly} + {Type <Return> for now, but then later remove\MessageBreak + the command \protect\usepackage{natbib} from the document} + \endinput}{} \@ifclassloaded{aguplus}{\PackageError{natbib} {The aguplus class already includes natbib coding,\MessageBreak so you should not add it explicitly} @@ -2110,12 +2292,34 @@ is read in after the main package file. % |\ifNAT@numbers| is \meta{false} by default (author--year) and switches % to \meta{true} for numerical citations. The flag |\ifNAT@super| indicates % if the numerical citation is to be done with superscripts. +% +% Note that changing |\ifNAT@numbers| or |\ifNAT@super| +% in the body of the text +% will not alter the way the citations are processed; +% their values at the end of the preamble determine the citation style for the +% rest of the document. % \begin{macrocode} \newif\ifNAT@numbers \NAT@numbersfalse \newif\ifNAT@super \NAT@superfalse % \end{macrocode} % \end{macro}\end{macro} % +% \begin{macro}{\NAT@merge} +% \changes{8.2}{2008 Jan 10}{(AO)Introduce \texttt{merge} package option} +% The package option |merge| allows multiple references to be merged under a single number +% in the bibliography, inspired by Thorsten Ohl's |mcite| package for \LaTeX. +% New syntax for the |\cite| command: e.g., |\cite{latex,*latex-companion}|, +% where the * signifies that the \LaTeX\ Companion and \LaTeX, a Document Formatting Language +% appear in the bibliography under the same number. +% |merge| applies only to the numerical citation mode; it is inactive in author-year mode. +% It is by default turned off (|\NAT@merge|${}={}$|\z@|). +% If |\NAT@merge|${}>{}$|\@ne|, all features are turned on. +% If |\NAT@merge|${}={}$|\@ne|, then the * syntax is active, but the merging is not done. +% \begin{macrocode} +\let\NAT@merge\z@ +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\DeclareOption} % \changes{5.0}{1994 May 18}{Add \LaTeXe{} options.} % \changes{5.3}{1994 Sep 13}{Add options \texttt{angle} and \texttt{curly}} @@ -2134,6 +2338,9 @@ is read in after the main package file. % The standard option \texttt{openbib} is also defined here so that its % behaviour is entirely under my control. Relying on the standard classes % can lead to trouble. +% \changes{8.2}{2008 Jul 02}{(AO) The value of \cs{NAT@sort} and \cs{NAT@cmprs} +% will be \cs{z@} or \cs{@ne}: something created by \cs{chardef}. +% This works better in \cs{ifnum} tests.} % \begin{macrocode} \DeclareOption{numbers}{\NAT@numberstrue \ExecuteOptions{square,comma,nobibstyle}} @@ -2164,14 +2371,20 @@ is read in after the main package file. \newif\ifNAT@openbib \NAT@openbibfalse \DeclareOption{openbib}{\NAT@openbibtrue} \DeclareOption{sectionbib}{\def\NAT@sectionbib{on}} -\def\NAT@sort{0} -\def\NAT@cmprs{0} -\DeclareOption{sort}{\def\NAT@sort{1}} -\DeclareOption{compress}{\def\NAT@cmprs{1}} -\DeclareOption{sort&compress}{\def\NAT@sort{1}\def\NAT@cmprs{1}} +\def\NAT@sort{\z@} +\def\NAT@cmprs{\z@} +\DeclareOption{sort}{\def\NAT@sort{\@ne}} +\DeclareOption{compress}{\def\NAT@cmprs{\@ne}} +\DeclareOption{sort&compress}{\def\NAT@sort{\@ne}\def\NAT@cmprs{\@ne}} +\DeclareOption{mcite}{\let\NAT@merge\@ne} +\DeclareOption{merge}{\@ifnum{\NAT@merge<\tw@}{\let\NAT@merge\tw@}{}} +\DeclareOption{elide}{\@ifnum{\NAT@merge<\thr@@}{\let\NAT@merge\thr@@}{}} \@ifpackageloaded{cite}{\PackageWarningNoLine{natbib} {The `cite' package should not be used\MessageBreak with natbib. Use option `sort' instead}\ExecuteOptions{sort}}{} +\@ifpackageloaded{mcite}{\PackageWarningNoLine{natbib} + {The `mcite' package should not be used\MessageBreak + with natbib. Use option `merge' instead}\ExecuteOptions{merge}}{} \@ifpackageloaded{citeref}{\PackageError{natbib} {The `citeref' package must be loaded after natbib}% {Move \protect\usepackage{citeref} to after \string\usepackage{natbib}}}{} @@ -2229,9 +2442,13 @@ is read in after the main package file. % \texttt{bst}-specific definitions. This definition is made here before % |\ExecuteOptions| so that options may make use of it; the option % \texttt{nobibstyle} turns it off, for example. +% +% Coding note (AO): if the csname has not been defined, then executing it simply +% executes |\relax|, so the coding here could be considerably simplified: +% just execute |\csname| |bibstyle@||#1||\endcsname| whether defined or not. +% (Done, PWD) % \begin{macrocode} -\renewcommand\bibstyle[1]{\@ifundefined{bibstyle@#1}{\relax} - {\csname bibstyle@#1\endcsname}} +\renewcommand\bibstyle[1]{\csname bibstyle@#1\endcsname} % \end{macrocode} % This is executed only when the auxiliary file is read in, and that is % when |\begin{document}| is issued. Thus this is well before any |\cite| @@ -2502,21 +2719,48 @@ is read in after the main package file. % equal to |\relax| so the condition is \meta{true}. Now any notes beginning % with an asterix will give trouble. % +% \changes{8.2}{2008 Jul 02}{(AO) Replace \cs{ } with \cs{NAT@spacechar} in four instances.} % \begin{macrocode} \newcommand\NAT@cite% - [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\ \fi + [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi #1\if*#3*\else\NAT@cmt#3\fi\NAT@@close\else#1\fi\endgroup} \newcommand\NAT@citenum% - [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\ \fi + [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi #1\if*#3*\else\NAT@cmt#3\fi\NAT@@close\else#1\fi\endgroup} \newcommand\NAT@citesuper[3]{\ifNAT@swa -\if*#2*\else#2\ \fi +\if*#2*\else#2\NAT@spacechar\fi \unskip\kern\p@\textsuperscript{\NAT@@open#1\NAT@@close}% - \if*#3*\else\ #3\fi\else #1\fi\endgroup} + \if*#3*\else\NAT@spacechar#3\fi\else #1\fi\endgroup} \providecommand\textsuperscript[1]{\mbox{$^{\mbox{\scriptsize#1}}$}} % \end{macrocode} % \end{macro}\end{macro}\end{macro}\end{macro} % +% \begin{macro}{\NAT@ifcat@num} +% This ``trick with the catcode'' is Donald Arseneau's. +% Used in |\NAT@citexnum| and |\NAT@make@cite@list|, +% it determines if the argument really is a number. It will be a +% non-number if the optional argument to |\bibitem| does not conform to any +% of the allowed \thestyle\ syntaxes, such as if \texttt{alph.bst} is used. +% +% When the macro is defined, the |\catcode| of the underscore character ought to be 8. +% Once the definition is complete, the macro can be used, and the current \cs{catcode} value of +% underscore will then be irrelevant. +% +% \changes{8.2}{2008 Jun 28}{(AO) Introduce \cs{NAT@ifcat@num} and ensure that +% the \cs{catcode} of the underscore is 8 at the time.} +% \begin{macrocode} +\begingroup \catcode`\_=8 +\gdef\NAT@ifcat@num#1{% + \ifcat_\ifnum\z@<0#1_\else A\fi + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +}% +\endgroup +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@citex} % \changes{5.5}{1995 Mar 21}{Is \cs{let} equal to the numerical or % author--year definition} @@ -2550,9 +2794,11 @@ is read in after the main package file. % parentheses, so they are really part of the main text. % % The temporary command |\@citeb| takes on the value of each of the keys in -% turn; |\@citea| is the separator between multiple citations, initially -% set to nothing, becoming |\NAT@sep| plus line-break suppression -% afterwards. The |\@firstofone| macro removes any leading blanks in +% turn; +% |\@citea| is prepended to a production and forms the separator between multiple citations, +% initially set to |\@empty|, +% becoming |\NAT@sep| plus line-break suppression afterwards. +% The |\@firstofone| macro removes any leading blanks in % |\@citeb|, making |\cite{key1, key2}| possible. If |\b@|\emph{key} is % not defined (as on the first run, for example), a warning is printed, and % a question mark inserted. Finally, the decoded label text is placed into @@ -2567,8 +2813,8 @@ is read in after the main package file. % that have name conflicts with \thestyle, they will also have conflicts with % standard \LaTeX\ too. % -% The number |\NAT@ctype| controls whether author (1), year (2), or number (0) -% is output by this macro. A value of 3 produces the cite alias. +% The value of |\NAT@ctype| controls whether number (0), author (1), year (2), or +% cite alias (3) is output by this macro. % % For compatibility with the \texttt{chapterbib} package of Donald Arseneau, % add |\@extra@b@citeb| to the cite key; this contains the number of the @@ -2580,23 +2826,37 @@ is read in after the main package file. % the same as the input. If compression of numerical lists is active % (|NAT@cmprs|=1) only the parenthetical output is affected. % -% The command |\@cprwrite| is defined in the \texttt{citeref} package. +% ^^A === Note (PWD): remove the following comment by AO from the printed output. +% ^^A Note (AO): an arguable misfeature of |\NAT@citexnum| is that it resists the user reordering +% ^^A the references: if the first citation to several references occurs within +% ^^A the argument of |\NAT@citexnum|, and if |\NAT@sort| is turned on, then +% ^^A the numbering of the references involved will not change even if their order +% ^^A is changed in the argument of the macro. The procedure |\NAT@citex| works likewise. +% % \changes{7.2}{2006 Jan 12}{Add \texttt{citeref} support} % \changes{8.1}{2007 Oct 30}{Add \cs{@empty} after \cs{@citeb}, as now in standard \LaTeX} -% \begin{macrocode} +% \changes{8.2}{2008 Jun 28}{(AO) Use \cs{NAT@ifcat@num} instead of unrolling.} +% \changes{8.2}{2008 Jul 01}{(AO) Provide a layer of abstraction to assignments +% to \cs{@citea}; here, this means using \cs{NAT@reset@citea}.} +% \changes{8.2}{2008 Jul 02}{(AO) Employ \cs{@ifxundefined} for use on \cs{@cprwrite}.} +% \changes{8.2}{2008 Jul 01}{(AO) Perform the \cs{ifnum} test on \cs{NAT@ctype} against +% \cs{z@}: \TeX\ finishes parsing the number and does the comparison earlier.} +% \changes{8.2}{2008 Jul 02}{(AO) Use \cs{@ifxundefined}, instead of \cs{@ifundefined}, on \cs{@cprwrite}.} +% \changes{8.2}{2008 Jul 01}{(AO) Use \cs{NAT@hyper@} to wrap up the hyperlink calls.} +% \changes{8.2}{2008 Jul 12}{(AO) Do not write .aux file entries in \cs{NAT@citexnum} +% or \cs{NAT@citex}; do this in \cs{NAT@sort@cites} where the keys will be in the user's order.} +% \begin{macrocode} \providecommand\@firstofone[1]{#1} \newcommand\NAT@citexnum{} \def\NAT@citexnum[#1][#2]#3{% - \NAT@sort@cites{#3}% - \let\@citea\@empty + \NAT@reset@parser + \NAT@sort@cites{#3}% + \NAT@reset@citea \@cite{\def\NAT@num{-1}\let\NAT@last@yr\relax\let\NAT@nm\@empty - \ifNAT@swa\else - \ifnum\NAT@ctype=0\if*#1*\else - #1\ \fi\fi\fi \@for\@citeb:=\NAT@cite@list\do - {\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% - \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}% - \@ifundefined{@cprwrite}{}{\expandafter\@cprwrite\@citeb=}\fi + {\@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \@ifundefined{b@\@citeb\@extra@b@citeb}{% {\reset@font\bfseries?} \NAT@citeundefined\PackageWarning{natbib}% @@ -2630,104 +2890,274 @@ is read in after the main package file. % \changes{7.2}{2006 Jan 12}{Add hyperlinks to compressed cites} % \changes{7.4a}{2006 Sep 06}{Add \cs{noexpand} to \cs{hyper@natlinkend}} % \changes{8.1}{2007 Oct 30}{Change \cs{edef} to \cs{protected@edef}} +% +% The code for parenthetical citations starts here. % \begin{macrocode} \ifNAT@swa - \ifnum\NAT@ctype>1\relax\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \ifnum\NAT@ctype=2\relax\NAT@test{\NAT@ctype}% - \else\NAT@alias - \fi\hyper@natlinkend\else - \ifnum\NAT@cmprs>0 - \begingroup\catcode`\_=8 - \ifcat _\ifnum\z@<0\NAT@num _\else A\fi - \global\let\NAT@nm=\NAT@num \else \gdef\NAT@nm{-2}\fi - \ifcat _\ifnum\z@<0\NAT@last@num _\else A\fi - \global\@tempcnta=\NAT@last@num \global\advance\@tempcnta by\@ne - \else \global\@tempcnta\m@ne\fi - \endgroup - \ifnum\NAT@nm=\@tempcnta - \ifx\NAT@last@yr\relax - \protected@edef\NAT@last@yr{\@citea \mbox{% - \noexpand\hyper@natlinkstart{\@citeb\@extra@b@citeb}{% - \noexpand\citenumfont{\NAT@num}}\noexpand\hyper@natlinkend}}% - \else - \protected@edef\NAT@last@yr{--\penalty\@m\mbox{% - \noexpand\hyper@natlinkstart{\@citeb\@extra@b@citeb}{% - \noexpand\citenumfont{\NAT@num}}\noexpand\hyper@natlinkend}}% - \fi - \else - \NAT@last@yr \@citea \mbox{\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - {\citenumfont{\NAT@num}}\hyper@natlinkend}% - \let\NAT@last@yr\relax - \fi - \else - \@citea \mbox{\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - {\citenumfont{\NAT@num}}\hyper@natlinkend}% - \fi - \fi - \def\@citea{\NAT@sep\penalty\@m\NAT@space}% % \end{macrocode} +% This portion comprises the code for year- and alias-type citations. +% \changes{8.2}{2008 Jul 01}{(AO) Perform the \cs{ifnum} test on \cs{NAT@ctype} +% against \cs{@ne}, resp. \cs{tw@}: no need to use \cs{relax}; +% \TeX\ finishes parsing the number and does the comparison earlier.} +% \changes{8.2}{2008 Jul 01}{(AO) Use \cs{NAT@hyper@} to wrap up the hyperlink calls.} +% \begin{macrocode} + \@ifnum{\NAT@ctype>\@ne}{% + \@citea + \NAT@hyper@{\@ifnum{\NAT@ctype=\tw@}{\NAT@test{\NAT@ctype}}{\NAT@alias}}% + }{% +% \end{macrocode} +% Here begins the code for the cases where |\NAT@ctype|${}\le{}$|1|, covering author and number citations. +% We start off with the code for compressed citations. +% +% The number of the current citation |\NAT@num| has been calculated by |\NAT@parse|. +% We also have state variables |\NAT@last@num| and |\NAT@last@yr|. +% |\NAT@last@num| represents |\NAT@num|'s value last time through this loop, $-1$ initially. +% |\NAT@last@yr| contains the production for the last citation, in case it requires deferring +% (if the last citation is to be compressed away, |\NAT@last@yr| will be clobbered by the current citation). +% +% We next determine if |\NAT@num| and |\NAT@last@num| are each numerical values. +% If |\NAT@num| is numerical, |\NAT@nm| is set to its value, to $-2$ if not. +% If |\NAT@last@num| is numerical, +% the counter |\@tempcnta| is set to its value, to $-1$ if not. +% +% Note (AO): the catcode of the |_| token stored in the macro's replacement +% part will be assigned at the time the macro definition is read in. +% Therefore, this macro, like |\NAT@make@cite@list|, needs to be defined accordingly. +% At the same time, the group created below along with +% the catcode assignment and global assignments, are all unnecessary. +% \changes{8.2}{2008 Jul 01}{(AO) Use \cs{NAT@ifcat@num} instead of unrolling the code in the macro. Global assignments are no longer necessary (which is good, since we are using \cs{@tempcnta}).} +% \changes{8.2}{2008 Jul 01}{(AO) Perform the \cs{@ifnum} test on \cs{NAT@cmprs} against \cs{z@}; \TeX\ finishes parsing the number and does the comparison earlier in the expansion.} +% \begin{macrocode} + \@ifnum{\NAT@cmprs>\z@}{% + \NAT@ifcat@num\NAT@num + {\let\NAT@nm=\NAT@num}% + {\def\NAT@nm{-2}}% + \NAT@ifcat@num\NAT@last@num + {\@tempcnta=\NAT@last@num\relax}% + {\@tempcnta\m@ne}% +% \end{macrocode} +% We enumerate the states in which we can arrive here. +% \begin{enumerate} +% \item[1] First citation in the list. +% \item[2] Second citation, and consecutive to the first, beginning an elision run. +% \item[3] Third or later, and consecutive to the previous, extending the run. +% \item[4] Second or later, but not consecutive to the previous, breaking the run. +% \item[5] Second or later, and duplicates the previous. Run or no, this one should be suppressed. +% \end{enumerate} +% Each of these cases is handled by its own part of the following code. +% +% \changes{8.2}{2008 Jan 10}{(AO)Introduce \texttt{merge} package option} +% The following section handles case (5). +% With the |merge| option in effect, we do nothing (this merges the current citation with the previous). +% Without, we do the same as cases (1) and (4) below. +% \begin{macrocode} + \@ifnum{\NAT@nm=\@tempcnta}{% + \@ifnum{\NAT@merge>\@ne}{}{\NAT@last@yr@mbox}% + }{% +% \end{macrocode} +% The following section handles cases (2) and (3). The value of |\NAT@last@yr| gets clobbered, +% which does the compressing. The citation stored in |\NAT@last@yr| will be the same except +% for the delimiter: the en-dash is used when there was an actual citation elided. +% \begin{macrocode} + \advance\@tempcnta by\@ne + \@ifnum{\NAT@nm=\@tempcnta}{% + \ifx\NAT@last@yr\relax + \def@NAT@last@yr{\@citea}% + \else + \def@NAT@last@yr{--\NAT@penalty}% + \fi + }{% +% \end{macrocode} +% The following section handles cases (1) and (4). +% |\NAT@last@yr| is expanded (actually producing something in case (4)), +% the current citation is produced, and |\NAT@last@yr| is re-initialized. +% \begin{macrocode} + \NAT@last@yr@mbox + }% + }% +% \end{macrocode} +% The code for compressed citations is complete. +% \begin{macrocode} + }{% +% \end{macrocode} +% The following code is executed when compression is turned off. +% We merge duplicates if |merge| is in effect. +% \begin{macrocode} + \@tempswatrue + \@ifnum{\NAT@merge>\@ne}{\@ifnum{\NAT@last@num=\NAT@num\relax}{\@tempswafalse}{}}{}% + \if@tempswa\NAT@citea@mbox\fi + }% + }% +% \end{macrocode} +% The code for author- and number-type citations is complete; +% we conclue the code for parenthetical citations. +% +% Ensure that proper punctuation appears before the second and following entries. +% \changes{8.2}{2008 Jul 01}{(AO) Provide a layer of abstraction to assignments to \cs{@citea}; +% here, this means using \cs{NAT@def@citea}.} +% \begin{macrocode} + \NAT@def@citea +% \end{macrocode} +% Here ends the portion relating to parenthetical citations. +% \begin{macrocode} + \else +% \end{macrocode} +% Here commences the code for textual citations. +% Note that compression (|\NAT@cmprs|) and merging (|\NAT@merge|) +% do not apply to such citations. +% % \changes{7.5}{2007 Feb 2}{Textual numerical cites print notes outside brackets} +% \changes{8.2}{2008 Jul 01}{(AO) With our abstraction of \cs{@citea}; +% we use wrappers \cs{NAT@def@citea@box} and \cs{NAT@hyper@citea}. +% Also \cs{NAT@penalty} in place of an explicit \cs{penalty}.} +% \changes{8.3}{2008 Sep 23}{Insert small space before \cs{NAT@@open}; this is +% simultaneously removed from superscript version of \cs{NAT@mbox}} +% \changes{8.3}{2008 Dec 5}{Use \cs{NAT@super@kern} for small spacing with +% superscripts only; else is \cs{relax}} % For textual citations, test what the output is to be (number, year, % author) and also test for comments. +% \changes{8.3}{2008 Dec 8}{Move \cs{NAT@@close} so post-comment inside braces} % \begin{macrocode} - \else - \ifcase\NAT@ctype\relax - \ifx\NAT@last@nm\NAT@nm \NAT@yrsep\penalty\@m\NAT@space\else - \@citea \NAT@test{1}\ \NAT@mbox{\NAT@@open}% - \fi \NAT@mbox{% - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - {\citenumfont{\NAT@num}}\hyper@natlinkend}% - \def\@citea{\NAT@mbox{\NAT@@close\NAT@sep\penalty\@m\ }}% - \or\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@test{\NAT@ctype}\hyper@natlinkend - \def\@citea{\NAT@sep\penalty\@m\ }% - \or\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@test{\NAT@ctype}\hyper@natlinkend - \def\@citea{\NAT@sep\penalty\@m\ }% - \or\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \def\@citea{\NAT@sep\penalty\@m\ }% + \ifcase\NAT@ctype + \ifx\NAT@last@nm\NAT@nm \NAT@yrsep\NAT@penalty\NAT@space\else + \@citea \NAT@test{\@ne}\NAT@spacechar\NAT@mbox{\NAT@super@kern\NAT@@open}% + \fi + \if*#1*\else#1\NAT@spacechar\fi + \NAT@mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}% + \NAT@def@citea@box + \or + \NAT@hyper@citea@space{\NAT@test{\NAT@ctype}}% + \or + \NAT@hyper@citea@space{\NAT@test{\NAT@ctype}}% + \or + \NAT@hyper@citea@space\NAT@alias \fi \fi - }}% - \ifnum\NAT@cmprs>0\relax\NAT@last@yr\fi - \ifNAT@swa\else\NAT@mbox{\NAT@@close}% - \ifnum\NAT@ctype=0\if*#2*\else - \NAT@cmt#2\fi - \fi\fi}{#1}{#2}} +% \end{macrocode} +% The code for textual citations is complete, along with the |\ifNAT@swa| started far above. +% +% Here ends the false branch of |\@ifundefined{b@\@citeb\@extra@b@citeb}|. +% \begin{macrocode} + }% +% \end{macrocode} +% Here ends the |\@for| loop. +% \begin{macrocode} + }% +% \end{macrocode} +% Clean up: the deferred portion from a possible parenthetical (|\NAT@last@yr|) citation. +% \begin{macrocode} + \@ifnum{\NAT@cmprs>\z@}{\NAT@last@yr}{}% +% \end{macrocode} +% More cleanup: the closing delimiter for textual (|\NAT@mbox|) citations is executed. +% \changes{8.2}{2008 Jan 10}{(AO)Introduce \texttt{merge} package option} +% (AO) I changed the |\ifnum| comparison to halt the parsing of the number earlier: +% otherwise \TeX\ would parse all the way to the |*| before calculating the |\ifnum| comparison. +% This feature of \TeX's scanner can cause difficult-to-understand problems. +% \changes{8.3}{2008 Dec 8}{Move \cs{NAT@@close} so post-comment inside braces} +% \begin{macrocode} + \ifNAT@swa\else + \@ifnum{\NAT@ctype=\z@}{% + \if*#2*\else\NAT@cmt#2\fi + }{}% + \NAT@mbox{\NAT@@close}% + \fi + }{#1}{#2}% +}% % \end{macrocode} % \end{macro} % +% \begin{macro}{\NAT@citea@mbox} +% \changes{8.2}{2008 Jan 10}{(AO)Introduce \texttt{merge} package option} +% \begin{macro}{\NAT@hyper@} +% \begin{macro}{\NAT@last@yr@mbox} +% \begin{macro}{\def@NAT@last@yr} +% \begin{macro}{\NAT@hyper@citea} +% \begin{macro}{\NAT@hyper@citea@space} +% Here we provide wrapper procedures for use in |\NAT@citexnum|. +% The |\NAT@citea@mbox| macro produces the citation itself preceded by appropriate punctuation, +% while |\def@NAT@last@yr| defines a macro |\NAT@last@yr| which, when expanded, produces the same thing. +% The procedure |\NAT@hyper@| is shorthand for a common hyperlink idiom involving +% the pair |\hyper@natlinkstart| and |\hyper@natlinkend|. +% Finally, |\NAT@last@yr@mbox| produces two citations: the first by expanding |\NAT@last@yr| (which it resets), +% the second by executing |\NAT@citea@mbox|. +% \begin{macrocode} +\def\NAT@citea@mbox{% + \@citea\mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}% +}% +\def\NAT@hyper@#1{% + \hyper@natlinkstart{\@citeb\@extra@b@citeb}#1\hyper@natlinkend +}% +\def\NAT@hyper@citea#1{% + \@citea + \NAT@hyper@{#1}% + \NAT@def@citea +}% +\def\NAT@hyper@citea@space#1{% + \@citea + \NAT@hyper@{#1}% + \NAT@def@citea@space +}% +\def\def@NAT@last@yr#1{% + \protected@edef\NAT@last@yr{% + #1% + \noexpand\mbox{% + \noexpand\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + {\noexpand\citenumfont{\NAT@num}}% + \noexpand\hyper@natlinkend + }% + }% +}% +\def\NAT@last@yr@mbox{% + \NAT@last@yr\let\NAT@last@yr\relax + \NAT@citea@mbox +}% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\NAT@test} % \changes{6.6}{1997 May 29}{Add macro} % \changes{7.4}{2006 Aug 18}{Fix bug by adding \cs{NAT@nmfmt}} +% \changes{8.2}{2008 Jul 16}{(AO) Perform tests on first argument using \cs{@ifnum}: that argument is always \cs{NAT@ctype} or one of its possible values.} +% \changes{8.2}{2008 Jul 16}{(AO) Use \cs{begingroup} instead of \cs{bgroup} for pushing \TeX's context stack.} +% \changes{8.3}{2008 Dec 4}{Remove the \cs{NAT@nmfmt} from name test; cannot see how it could help; only hinders} % For numerical mode, need to test if there really is a name or date; if a % numerical \texttt{.bst} file is being used, there will not be any names or % dates. This macro tests and writes |\NAT@nm| or |\NAT@date| according to % its argument being 1 or 2. % \begin{macrocode} -\newcommand\NAT@test[1]{\ifnum#1=1 \ifx\NAT@nmfmt{\NAT@nm}\NAT@noname - {\reset@font\bfseries(author?)}\PackageWarning{natbib} - {Author undefined for citation`\@citeb' - \MessageBreak - on page \thepage}\else \NAT@nm \fi - \else \if\relax\NAT@date\relax - {\reset@font\bfseries(year?)}\PackageWarning{natbib} - {Year undefined for citation`\@citeb' - \MessageBreak - on page \thepage}\else \NAT@date \fi \fi} +\newcommand\NAT@test[1]{% + \@ifnum{#1=\@ne}{% + \ifx\NAT@nm\NAT@noname + \begingroup\reset@font\bfseries(author?)\endgroup + \PackageWarning{natbib}{% + Author undefined for citation`\@citeb' \MessageBreak on page \thepage% + }% + \else \NAT@nm + \fi + }{% + \if\relax\NAT@date\relax + \begingroup\reset@font\bfseries(year?)\endgroup + \PackageWarning{natbib}{% + Year undefined for citation`\@citeb' \MessageBreak on page \thepage% + }% + \else \NAT@date + \fi + }% +}% % \end{macrocode} % \end{macro} % % \begin{macro}{\citenumfont} % \changes{7.0}{1999 May 7}{Add macro to format numerical citations} -% To set the numerical citations in a different font, define |\citenumfont|. +% \changes{8.3}{2008 Nov 19}{Initialize as \cs{@empty} not \cs{relax}} +% To set the numerical citations in a different font, redefine |\citenumfont|. % \begin{macrocode} -\let\citenumfont=\relax +\let\citenumfont=\@empty % \end{macrocode} % \end{macro} % @@ -2772,23 +3202,33 @@ is read in after the main package file. % The command |\@cprwrite| is defined in the \texttt{citeref} package. % \changes{7.2}{2006 Jan 12}{Add \texttt{citeref} support} % \changes{8.1}{2007 Oct 30}{Add \cs{@empty} after \cs{@citeb}, as now in standard \LaTeX} +% \changes{8.2}{2008 Jul 01}{(AO) Provide a layer of abstraction to assignments to \cs{@citea}; +% here, this means using \cs{NAT@reset@citea}.} +% \changes{8.2}{2008 Jul 02}{(AO) Employ \cs{@ifxundefined} for use on \cs{@cprwrite}.} +% \changes{8.3}{2008 Aug 27}{Add \cs{@safe@activesfalse} for babel compatibility} +% \changes{8.2}{2008 Jul 12}{(AO) Do not write .aux file entries in \cs{NAT@citexnum} or \cs{NAT@citex}; +% do this in \cs{NAT@sort@cites} where the keys will be in the user's order.} % \begin{macrocode} \newcommand\NAT@citex{} \def\NAT@citex% [#1][#2]#3{% + \NAT@reset@parser \NAT@sort@cites{#3}% - \let\@citea\@empty + \NAT@reset@citea \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty \@for\@citeb:=\NAT@cite@list\do - {\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% - \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}% - \@ifundefined{@cprwrite}{}{\expandafter\@cprwrite\@citeb=}\fi + {\@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse +% \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}% Move to \NAT@sort@cites +% \@ifxundefined\@cprwrite{}{\expandafter\@cprwrite\@citeb=}% Move to \NAT@cite@list@append +% \fi \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea% {\reset@font\bfseries ?}\NAT@citeundefined \PackageWarning{natbib}% {Citation `\@citeb' on page \thepage \space undefined}\def\NAT@date{}}% {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year - \NAT@parse{\@citeb}% + \NAT@parse{\@citeb}% \ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{% \let\NAT@name=\NAT@all@names \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}% @@ -2833,13 +3273,15 @@ is read in after the main package file. % option, it becomes |\mbox|. This was a special request. % % \changes{7.1}{2003 June 6}{Add test for missing letter with multiple cites} +% \changes{8.2}{2008 Jul 01}{(AO) Use \cs{NAT@hyper@} to wrap up the hyperlink calls in seven instances.} +% \changes{8.2}{2008 Jul 01}{(AO) Provide a layer of abstraction to assignments to \cs{@citea}; +% here, this means using \cs{NAT@def@citea}.} % Add a test for a missing extra letter in multiple citations. This can happen % with the \texttt{chicago} style, for example. Pointed out by Frank Mittelbach. % \begin{macrocode} \ifNAT@swa\ifcase\NAT@ctype \if\relax\NAT@date\relax - \@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\NAT@date\hyper@natlinkend + \@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}\NAT@date}% \else \ifx\NAT@last@nm\NAT@nm\NAT@yrsep \ifx\NAT@last@yr\NAT@year @@ -2848,36 +3290,36 @@ is read in after the main package file. {Multiple citation on page \thepage: same authors and year\MessageBreak without distinguishing extra letter,\MessageBreak appears as question mark}\fi - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab - \hyper@natlinkend - \else\unskip\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date - \hyper@natlinkend + \NAT@hyper@{\NAT@exlab}% + \else\unskip\NAT@spacechar + \NAT@hyper@{\NAT@date}% \fi - \else\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}% - \hyper@natlinkbreak{\NAT@aysep\ }{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend + \else + \@citea\NAT@hyper@{% + \NAT@nmfmt{\NAT@nm}% + \hyper@natlinkbreak{% + \NAT@aysep\NAT@spacechar}{\@citeb\@extra@b@citeb + }% + \NAT@date + }% \fi \fi - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \fi \def\@citea{\NAT@sep\ }% + \or\@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}% + \or\@citea\NAT@hyper@{\NAT@date}% + \or\@citea\NAT@hyper@{\NAT@alias}% + \fi \NAT@def@citea % \end{macrocode} % Begin textual citation. Do same checks for repeated names and years. % Optional notes are added here, not in |\NAT@cite|, which means for % multiple citations, each one will receive the notes in the year part. % (Pre-notes are questionable for this, but include them anyway.) % \changes{6.6}{1997 July 5}{Fix closing brace bug} +% \changes{8.2}{2008 Jul 01}{(AO) Use \cs{NAT@hyper@} to wrap up the hyperlink calls in four instances.} % \begin{macrocode} - \else\ifcase\NAT@ctype + \else + \ifcase\NAT@ctype \if\relax\NAT@date\relax - \@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend + \@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}% \else \ifx\NAT@last@nm\NAT@nm\NAT@yrsep \ifx\NAT@last@yr\NAT@year @@ -2886,26 +3328,29 @@ is read in after the main package file. {Multiple citation on page \thepage: same authors and year\MessageBreak without distinguishing extra letter,\MessageBreak appears as question mark}\fi - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab - \hyper@natlinkend - \else\unskip\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date - \hyper@natlinkend + \NAT@hyper@{\NAT@exlab}% + \else + \unskip\NAT@spacechar + \NAT@hyper@{\NAT@date}% \fi - \else\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}% - \hyper@natlinkbreak{\ \NAT@@open\if*#1*\else#1\ \fi}% - {\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend\fi + \else + \@citea\NAT@hyper@{% + \NAT@nmfmt{\NAT@nm}% + \hyper@natlinkbreak{\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi}% + {\@citeb\@extra@b@citeb}% + \NAT@date + }% + \fi \fi - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \fi \if\relax\NAT@date\relax\def\@citea{\NAT@sep\ }% - \else\def\@citea{\NAT@@close\NAT@sep\ }\fi + \or\@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}% + \or\@citea\NAT@hyper@{\NAT@date}% + \or\@citea\NAT@hyper@{\NAT@alias}% + \fi + \if\relax\NAT@date\relax + \NAT@def@citea + \else + \NAT@def@citea@close + \fi \fi }}\ifNAT@swa\else\if*#2*\else\NAT@cmt#2\fi \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{#1}{#2}} @@ -2913,6 +3358,59 @@ is read in after the main package file. % % \end{macro}\end{macro} % +% \begin{macro}{\NAT@spacechar} +% \begin{macro}{\NAT@separator} +% \changes{8.3}{2008 Sep 23}{Remove \cs{NAT@space} from definition; +% add explicitly elsewhere} +% \begin{macro}{\NAT@reset@citea} +% \begin{macro}{\NAT@def@citea} +% \begin{macro}{\NAT@def@citea@space} +% \changes{8.3}{2008 Dec 5}{Add macro} +% \begin{macro}{\NAT@def@citea@close} +% \begin{macro}{\NAT@def@citea@box} +% \changes{8.3}{2008 Sep 23}{Fix for better spacing and separations with superscripts} +% We introduce |\NAT@spacechar|, which takes the place of the space character in all +% productions. Note that the macro |\NAT@space| is variable: it is the space character +% except for superscript citations, where it becomes |\relax|. This is to suppress +% spacing between superscripted citations. +% +% The macro |\NAT@separator| is the commonly employed separator between citations. +% +% The procedures |\NAT@reset@citea|, |\NAT@def@citea|, and |\NAT@def@citea@close| +% manage the |\@citea| macro for |\NAT@citex|, +% while |\NAT@def@citea@box| acts only for |\NAT@citexnum| in textual mode. +% Any assignment to |\@citea| is done by one of these procedures. +% +% Note that |\NAT@def@citea@box| uses the fixed |\NAT@spacechar|; this allows +% a space to appear between multiple superscripted citations that appear with the author +% names, whereas multiple superscripts (either for repeated authors or no authors) +% have no space between them. +% +% And |\NAT@def@citea| sets the variable |\NAT@space| between citations, while +% |\NAT@def@citea@space| uses the fixed space. This is employed with |\citet| +% in numerical mode, for author, year, alias only. It makes a difference for +% superscripts, allowing space to appear between such multiples. +% +% An extension to \thestyle\ could change these procedures to effect more sophisticated +% behaviour of the punctuation between textual citations. +% \begin{macrocode} +\def\NAT@spacechar{\ }% +\def\NAT@separator{\NAT@sep\NAT@penalty}% +\def\NAT@reset@citea{\c@NAT@ctr\@ne\let\@citea\@empty}% +\def\NAT@def@citea{\def\@citea{\NAT@separator\NAT@space}}% +\def\NAT@def@citea@space{\def\@citea{\NAT@separator\NAT@spacechar}}% +\def\NAT@def@citea@close{\def\@citea{\NAT@@close\NAT@separator\NAT@space}}% +\def\NAT@def@citea@box{\def\@citea{\NAT@mbox{\NAT@@close}\NAT@separator\NAT@spacechar}}% +% \end{macrocode} +% +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\NAT@@open} % \changes{6.6}{1997 May 26}{Add macro} % \begin{macro}{\NAT@@close} @@ -2969,7 +3467,9 @@ is read in after the main package file. % \begin{macrocode} \newcommand\shortcites[1]{% \@bsphack\@for\@citeb:=#1\do - {\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + {\@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}\@esphack} % \end{macrocode} % \end{macro} @@ -3080,6 +3580,12 @@ is read in after the main package file. % \changes{6.8a}{1998 May 14}{\cs{@biblabel} redefined only for numericals} % \changes{7.5}{2007 Feb 2}{Saving user definitions of \cs{@biblabel} done differently} % \changes{7.5}{2007 Feb 2}{\cs{NAT@idxtxt} defaults to appropriate style in numerical mode} +% \changes{8.2}{2008 Jun 26}{(AO) use \cs{NAT@space} and \cs{NAT@penalty} for +% author-year citation style as well as in \cs{NAT@citexnum}} +% \changes{8.2}{2008 Jul 02}{(AO) use \cs{NAT@spacechar} in \cs{NAT@idxtxt}} +% \changes{8.3}{2008 Sep 23}{Remove small space before \cs{textsuperscript} in +% superscript version of \cs{NAT@mbox}} +% \changes{8.3}{2008 Dec 5}{Define \cs{NAT@super@kern} for small spacing with superscripts} % The four internal macros that have different definitions depending on the % citation style have been defined with different names; now set the macros % to be executed to that set that is actually wanted. This is determined by @@ -3091,27 +3597,35 @@ is read in after the main package file. % extra labels (the letters added to the dates); these are to be suppressed % for numerical citations. % \begin{macrocode} -\newcommand\NAT@set@cites{\ifNAT@numbers - \ifNAT@super \let\@cite\NAT@citesuper - \def\NAT@mbox##1{\unskip\nobreak\hspace{1\p@}\textsuperscript{##1}}% - \let\citeyearpar=\citeyear - \let\NAT@space\relax\else - \let\NAT@mbox=\mbox - \let\@cite\NAT@citenum \def\NAT@space{ }\fi - \let\@citex\NAT@citexnum - \let\@biblabel\NAT@biblabelnum - \let\@bibsetup\NAT@bibsetnum - \renewcommand\NAT@idxtxt{\NAT@name\ \NAT@open\NAT@num\NAT@close}% - \def\natexlab##1{}% - \else - \let\@cite\NAT@cite - \let\@citex\NAT@citex - \let\@biblabel\NAT@biblabel - \let\@bibsetup\NAT@bibsetup - \let\NAT@space\relax - \renewcommand\NAT@idxtxt{\NAT@name\ \NAT@open\NAT@date\NAT@close}% - \def\natexlab##1{##1}% - \fi} +\newcommand\NAT@set@cites{% + \ifNAT@numbers + \ifNAT@super \let\@cite\NAT@citesuper + \def\NAT@mbox##1{\unskip\nobreak\textsuperscript{##1}}% + \let\citeyearpar=\citeyear + \let\NAT@space\relax + \def\NAT@super@kern{\kern\p@}% + \else + \let\NAT@mbox=\mbox + \let\@cite\NAT@citenum + \let\NAT@space\NAT@spacechar + \let\NAT@super@kern\relax + \fi + \let\@citex\NAT@citexnum + \let\@biblabel\NAT@biblabelnum + \let\@bibsetup\NAT@bibsetnum + \renewcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@num\NAT@close}% + \def\natexlab##1{}% + \def\NAT@penalty{\penalty\@m}% + \else + \let\@cite\NAT@cite + \let\@citex\NAT@citex + \let\@biblabel\NAT@biblabel + \let\@bibsetup\NAT@bibsetup + \let\NAT@space\NAT@spacechar + \let\NAT@penalty\@empty + \renewcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@date\NAT@close}% + \def\natexlab##1{##1}% + \fi} \AtBeginDocument{\NAT@set@cites} % \end{macrocode} % \end{macro} @@ -3161,14 +3675,15 @@ is read in after the main package file. \fi} % \end{macrocode} % -% \changes{7.2}{2006 Jan 12}{Previously |hyperref| would turn off compression; now allow this} +% \changes{7.2}{2006 Jan 12}{Previously \texttt{hyperref} would turn off compression; now allow this} +% \changes{8.2}{2008 Jul 13}{(AO) Commented-out code has been made into a comment.} % With the \texttt{hyperref} package, compression of numerical citations % was turned off in earlier versions. As of 7.2, remove this constraint, and % make the first and last numbers in the compressed range into links. -% \begin{macrocode} +% \begin{verbatim} % \AtBeginDocument{\@ifpackageloaded{hyperref}{% -% \ifnum\NAT@sort=2\def\NAT@sort{1}\fi}{}} -% \end{macrocode} +% \ifnum\NAT@sort=\tw@\def\NAT@sort{\@ne}\fi}{}} +% \end{verbatim} % % \subsection{The Citations} % @@ -3178,6 +3693,7 @@ is read in after the main package file. % \changes{6.6}{1997 May 26}{Define with \cs{ifNAT@par} on} % \changes{6.6}{1997 May 27}{Redefine for new coding of \cs{@citex}} % \changes{6.8}{1998 Feb 19}{Place inside a group} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@}: allow for tighter \cs{ifnum} comparisons.} % Textual citations are made with the |\citet| command, which has a starred % form for full authors, and may have one or two optional arguments for notes. % @@ -3217,7 +3733,7 @@ is read in after the main package file. \newif\ifNAT@full\NAT@fullfalse \newif\ifNAT@swa \DeclareRobustCommand\citet - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \newcommand\NAT@citetp{\@ifnextchar[{\NAT@@citetp}{\NAT@@citetp[]}} \newcommand\NAT@@citetp{} @@ -3232,6 +3748,7 @@ is read in after the main package file. % \changes{6.6}{1997 May 26}{Define with \cs{ifNAT@par} on} % \changes{6.6}{1997 May 27}{Redefine for new coding of \cs{@citex}} % \changes{6.8}{1998 Feb 19}{Place inside a group} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@}: allow for tighter \cs{ifnum} comparisons.} % Parenthetical citations are made with the |\citep| command, which has a % starred form for full authors, and may have one or two optional arguments for % notes. @@ -3245,7 +3762,7 @@ is read in after the main package file. % to the older syntax |\cite|\oarg{pre}\oarg{post}\marg{key}. % \begin{macrocode} \DeclareRobustCommand\citep - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@partrue \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} % \end{macrocode} % \end{macro} @@ -3257,6 +3774,7 @@ is read in after the main package file. % \changes{6.5}{1997 Jan 30}{Declare obsolete, retained for compatibility} % \changes{6.6}{1997 May 27}{Redefine for new coding of \cs{@citex}} % \changes{6.8}{1998 Feb 19}{Place inside a group} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@}: allow for tighter \cs{ifnum} comparisons.} % The |\cite| command was originally used to produce both textual and % parenthetical citations; with an option argument, even an empty one, % the citation was parenthical. I now recommend the use of |\citet| and @@ -3267,7 +3785,7 @@ is read in after the main package file. % author--year mode, this flag depends on presence or absence of notes. % \begin{macrocode} \DeclareRobustCommand\cite - {\begingroup\def\NAT@ctype{0}\NAT@partrue\NAT@swatrue + {\begingroup\let\NAT@ctype\z@\NAT@partrue\NAT@swatrue \@ifstar{\NAT@fulltrue\NAT@cites}{\NAT@fullfalse\NAT@cites}} \newcommand\NAT@cites{\@ifnextchar [{\NAT@@citetp}{% \ifNAT@numbers\else @@ -3287,6 +3805,7 @@ is read in after the main package file. % \changes{6.6}{1997 Jun 23}{Add macro, like \cs{citep} without parentheses} % \changes{6.8}{1998 Feb 19}{Place inside a group} % \changes{7.0}{1999 May 21}{Include in subpack} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@}: allow for tighter \cs{ifnum} comparisons.} % An alternative form of citation is one in which the parentheses are not % printed. This was originally requested by Alexander Holt, who wanted it to be % the same as |\citet| but without any braces; since then James Bednar has asked @@ -3304,16 +3823,17 @@ is read in after the main package file. % should be added later. % \begin{macrocode} \DeclareRobustCommand\citealt - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@parfalse \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\citealp - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@parfalse \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} % \end{macrocode} % \end{macro}\end{macro} % % \begin{macro}{\citenum} % \changes{7.5}{2007 Feb 2}{Add macro to print citation number number} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@}: allow for tighter \cs{ifnum} comparisons.} % With version~7.5, |\citenum| is a new feature: it prints the citation number % just like |\citealp| but without authors, and without raising it in superscript % mode. This was requested by Antony Stone who @@ -3323,8 +3843,9 @@ is read in after the main package file. % % \begin{macrocode} \DeclareRobustCommand\citenum - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@parfalse\let\textsuperscript\ - \NAT@citexnum[][]} + {\begingroup + \NAT@swatrue\let\NAT@ctype\z@\NAT@parfalse\let\textsuperscript\NAT@spacechar + \NAT@citexnum[][]} % \end{macrocode} % \end{macro} % @@ -3336,12 +3857,13 @@ is read in after the main package file. % \changes{6.4}{1996 Oct 2}{Add dummy macros for \texttt{hyperref.sty}} % \changes{6.6}{1997 May 27}{Define with \cs{@citex} and \cs{NAT@ctype}} % \changes{6.8}{1998 Feb 19}{Place inside a group} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{@ne}: allow for tighter \cs{ifnum} comparisons.} % In order to refer to the authors without year or number, provide % |\citeauthor| and |\citeauthor*|; for historical reasons, keep % |\citefullauthor|. % \begin{macrocode} \DeclareRobustCommand\citeauthor - {\begingroup\NAT@swafalse\def\NAT@ctype{1}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\@ne\NAT@parfalse \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} % \end{macrocode} % \end{macro} @@ -3356,6 +3878,7 @@ is read in after the main package file. % \changes{7.0}{1999 May 10}{Add macro} % \begin{macro}{\Citeauthor} % \changes{7.0}{1999 May 10}{Add macro} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{z@} (resp. \cs{@ne}): allow for tighter \cs{ifnum} comparisons.} % When a textual citation occurs at the beginning of a sentence and the first % name is something like ``de la Maire'', it needs to be capitalized. This is % done with the |\NAT@up| command that is redefined to be |\NAT@Up|. @@ -3364,23 +3887,23 @@ is read in after the main package file. % eventually ask for it, so do it now. % \begin{macrocode} \DeclareRobustCommand\Citet - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citep - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@partrue \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citealt - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@parfalse \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citealp - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@parfalse \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citeauthor - {\begingroup\NAT@swafalse\def\NAT@ctype{1}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\@ne\NAT@parfalse \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} % \end{macrocode} @@ -3394,20 +3917,22 @@ is read in after the main package file. % \changes{6.4}{1996 Oct 2}{Add dummy macros for \texttt{hyperref.sty}} % \changes{6.6}{1997 May 27}{Define with \cs{@citex} and \cs{NAT@ctype}} % \changes{6.8}{1998 Feb 19}{Place inside a group} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{tw@}: allow for tighter \cs{ifnum} comparisons.} % Similarly for the year only. % \begin{macrocode} \DeclareRobustCommand\citeyear - {\begingroup\NAT@swafalse\def\NAT@ctype{2}\NAT@parfalse\NAT@citetp} + {\begingroup\NAT@swafalse\let\NAT@ctype\tw@\NAT@parfalse\NAT@citetp} % \end{macrocode} % \end{macro} % % \begin{macro}{\citeyearpar} % \changes{6.6}{1997 May 17}{Add macro} % \changes{6.8}{1998 Feb 19}{Place inside a group} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{tw@}: allow for tighter \cs{ifnum} comparisons.} % I have often been asked for a version of |\citeyear| in parentheses. % \begin{macrocode} \DeclareRobustCommand\citeyearpar - {\begingroup\NAT@swatrue\def\NAT@ctype{2}\NAT@partrue\NAT@citetp} + {\begingroup\NAT@swatrue\let\NAT@ctype\tw@\NAT@partrue\NAT@citetp} % \end{macrocode} % \end{macro} % @@ -3447,6 +3972,7 @@ is read in after the main package file. % \changes{6.9}{1999 Jan 22}{Add macro} % \begin{macro}{\citepalias} % \changes{6.9}{1999 Jan 22}{Add macro} +% \changes{8.2}{2008 Jul 01}{(AO) Assign \cs{NAT@ctype} with \cs{let} \cs{thr@@}: allow for tighter \cs{ifnum} comparisons.} % An alias is an alternative designation for a reference, something like [ABG] % in place of [Alpher, Bethe, Gamow, 1980]. The alias is defined with % |\defcitealias| and used with |\citetalias| and |\citepalias|. @@ -3461,9 +3987,9 @@ is read in after the main package file. {\PackageWarning{natbib}{Overwriting existing alias for citation #1}} \@namedef{al@#1\@extra@b@citeb}{#2}} \DeclareRobustCommand\citetalias{\begingroup - \NAT@swafalse\def\NAT@ctype{3}\NAT@parfalse\NAT@citetp} + \NAT@swafalse\let\NAT@ctype\thr@@\NAT@parfalse\NAT@citetp} \DeclareRobustCommand\citepalias{\begingroup - \NAT@swatrue\def\NAT@ctype{3}\NAT@partrue\NAT@citetp} + \NAT@swatrue\let\NAT@ctype\thr@@\NAT@partrue\NAT@citetp} % \end{macrocode} % \end{macro}\end{macro}\end{macro} % @@ -3478,7 +4004,9 @@ is read in after the main package file. % \begin{macrocode} \renewcommand\nocite[1]{\@bsphack \@for\@citeb:=#1\do{% + \@safe@activestrue \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi \if*\@citeb\else \@ifundefined{b@\@citeb\@extra@b@citeb}{% @@ -3521,15 +4049,27 @@ is read in after the main package file. % is first necessary to expand |\b@|\emph{key} into a temporary command % |\NAT@temp|, which is then used as the argument of |\NAT@split|, which % makes the individual assignments. +% +% When the |\bibcite| command has been written by standard LaTeX, its second argument +% will consist of a number instead of what \thestyle\ expects (four brace-delimited things). +% One must not assume that things are as we would like. +% \changes{8.2}{2008 Jul 01}{(AO) Give \cs{NAT@split} a good argument, even when \cs{NAT@temp} is poorly constructed.}% +% \changes{8.2}{2008 Jul 16}{(AO) Avoid global definition of \cs{NAT@temp}}% +% \changes{8.2}{2008 Sep 12}{(AO) Change pattern part of \cs{NAT@split} to avoid problems with standard .aux files.}% % \begin{macrocode} -\newcommand\NAT@parse[1]{{% - \let\protect=\@unexpandable@protect\let~\relax - \let\active@prefix=\@gobble - \xdef\NAT@temp{\csname b@#1\@extra@b@citeb\endcsname}}% - \expandafter\NAT@split\NAT@temp - \expandafter\NAT@parse@date\NAT@date??????@@% - \ifciteindex\NAT@index\fi -} +\newcommand\NAT@parse[1]{% + \begingroup + \let\protect=\@unexpandable@protect + \let~\relax + \let\active@prefix=\@gobble + \edef\NAT@temp{\csname b@#1\@extra@b@citeb\endcsname}% + \aftergroup\NAT@split + \expandafter + \endgroup + \NAT@temp{}{}{}{}{}@@% + \expandafter\NAT@parse@date\NAT@date??????@@% + \ifciteindex\NAT@index\fi +}% % \end{macrocode} % % The |\active@prefix| command appearing in \texttt{babel} causes problems @@ -3545,15 +4085,28 @@ is read in after the main package file. % \changes{5.5}{1995 May 14}{Fix coding slightly} % \changes{5.5}{1995 May 18}{Renamed from \cs{@citez}} % \changes{6.0}{1995 Sep 4}{Recode for new \cs{bibcite} structure} +% \changes{8.2}{2008 Jul 13}{(AO) Protect against case where \cs{NAT@num} is defined to be the same as \cs{@empty} (malformed \texttt{.aux} file).} +% \changes{8.2}{2008 Jul 16}{(AO) Arrange to restore original state (in case \cs{cite} argument is empty).}% +% \changes{8.2}{2008 Sep 12}{(AO) Change pattern part of \cs{NAT@split} to avoid problems with standard .aux files.}% % The actual assignments of the author--year and numerical label texts to % the corresponding commands is carried out by |\NAT@split|. If the long % author list is missing (argument |#4|), it is set equal to the short % list. +% +% Query (AO): why are these assignments |\global|? I would not think it necessary. % \begin{macrocode} -\newcommand\NAT@split[4]{% +\def\NAT@split#1#2#3#4#5@@{% \gdef\NAT@num{#1}\gdef\NAT@name{#3}\gdef\NAT@date{#2}% \gdef\NAT@all@names{#4}% - \ifx\NAT@noname\NAT@all@names \gdef\NAT@all@names{#3}\fi} + \ifx\NAT@num\@empty\gdef\NAT@num{0}\fi + \ifx\NAT@noname\NAT@all@names \gdef\NAT@all@names{#3}\fi +}% +\def\NAT@reset@parser{% + \global\let\NAT@num\@empty + \global\let\NAT@name\@empty + \global\let\NAT@date\@empty + \global\let\NAT@all@names\@empty +}% % \end{macrocode} % \end{macro} % @@ -3590,11 +4143,13 @@ is read in after the main package file. % \changes{6.0}{1995 Sep 21}{Add macro} % \changes{6.9}{1999 Jan 22}{Allow \cs{makeindex} to be issued before package % loaded} +% \changes{8.2}{2008 Jul 02}{(AO) Replace \cs{ } with \cs{NAT@spacechar} in \cs{NAT@idxtxt}.} % To make an entry in the index for every citation, I have added % |\NAT@index| to the |\NAT@parse| command. This will do nothing unless % |\makeindex| has been issued in the preamble, in which case it writes the % citation information to the \texttt{.idx} file by means of the standard -% \LaTeX\ internal |\@wrindex|. The actual format of the citation +% \LaTeX\ internal |\@wrindex| (which contains the closing |\endgroup\@esphack|). +% The actual format of the citation % information is contained in |\NAT@idxtxt| which a user may redefine if % needed. % \begin{macrocode} @@ -3603,13 +4158,14 @@ is read in after the main package file. \renewcommand\makeindex{\NAT@makeindex \renewcommand\NAT@index{\@bsphack\begingroup \def~{\string~}\@wrindex{\NAT@idxtxt}}} -\newcommand\NAT@idxtxt{\NAT@name\ \NAT@open\NAT@date\NAT@close} +\newcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@date\NAT@close} % \end{macrocode} % If |\makeindex| has already been issued before \thestyle\ is loaded, it % does not contain these extra features. Thus issue it once more, but only with % the extra features. +% \changes{8.2}{2008 Jul 02}{(AO) Employ \cs{@ifxundefined} for use on \cs{@indexfile}.} % \begin{macrocode} -\@ifundefined{@indexfile}{}{\let\NAT@makeindex\relax\makeindex} +\@ifxundefined\@indexfile{}{\let\NAT@makeindex\relax\makeindex} % \end{macrocode} % \end{macro}\end{macro} % \begin{macro}{\ifciteindex} @@ -3637,15 +4193,19 @@ is read in after the main package file. % \texttt{.idx} and \texttt{.ind}. To make the automatic index entries go to % a different set, redefine |\citeindextype|. % -% The |\mbox{}| before |\index| below prevents vertical shifts when the -% |\cite| command comes at the beginning of a tabular column. Heaven knows why. +% \changes{8.3}{2008 Dec 03}{Remove \cs{mbox} from \cs{NAT@exp}} +% There used to be an +% |\mbox{}| before |\index| below which apparently ``prevents vertical shifts when the +% |\cite| command comes at the beginning of a tabular column.'' +% However, it also causes crashes when listing the bibliography because it comes +% before the first |\item| command. Removed. % % \begin{macrocode} \newcommand\citeindextype{default} \newcommand\NAT@index@alt{{\let\protect=\noexpand\let~\relax \xdef\NAT@temp{\NAT@idxtxt}}\expandafter\NAT@exp\NAT@temp\@nil} \newcommand\NAT@exp{} -\def\NAT@exp#1\@nil{\mbox{}\index[\citeindextype]{#1}} +\def\NAT@exp#1\@nil{\index[\citeindextype]{#1}} \AtBeginDocument{% \@ifpackageloaded{index}{\let\NAT@index=\NAT@index@alt}{}} @@ -3721,10 +4281,10 @@ is read in after the main package file. \def\NAT@bare#1(#2)#3(@)#4\@nil#5{% %<*all|apalike|authordate> \if @#2 - \expandafter\NAT@apalk#1, , \@nil{#5}\else + \expandafter\NAT@apalk#1, , \@nil{#5}% + \else %</all|apalike|authordate> - \stepcounter{NAT@ctr}% - \NAT@wrout{\arabic {NAT@ctr}}{#2}{#1}{#3}{#5} + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{#3}{#5}% %<all|apalike|authordate>\fi } % \end{macrocode} @@ -3775,10 +4335,7 @@ is read in after the main package file. % counter value in as the argument to |\@lbibitem| which is then treated as % a non-author--year label. % \begin{macrocode} -\renewcommand\bibitem{% - \@ifnextchar[{\@lbibitem}{% - \global\NAT@stdbsttrue - \stepcounter{NAT@ctr}\@lbibitem[\arabic{NAT@ctr}]}} +\renewcommand\bibitem{\@ifnextchar[{\@lbibitem}{\@lbibitem[]}}% % \end{macrocode} % Write the label with |\item| in the bibliography listing with the current % value of |\NAT@num|, if it exists. This will either be the sequential @@ -3791,27 +4348,314 @@ is read in after the main package file. % % \changes{6.8b}{1998 July 6}{To work with \texttt{chapterbib} and % \texttt{backref}} +% \changes{8.2}{2008 Jan 10}{(AO) +% Introduce, for \texttt{merge} package option, \cs{NAT@bibitem@first@sw}} % The \texttt{hyperref} package can call the \texttt{backref} package which % do not work with the \texttt{chapterbib} package. I have arranged with % Sebastian Rahtz to add the compatibility via \thestyle. Thus I add a fix to % include the |\@extra@b@citeb| suffix to the |\br@#2| commands called by % \texttt{backref}. +% +% The optional arguments to the cite key have the effect of giving a meaning +% to the |\BibitemOpen| and |\BibitemShut| control sequence names. % \begin{macrocode} +\let\NAT@bibitem@first@sw\@secondoftwo \def\@lbibitem[#1]#2{% \if\relax\@extra@b@citeb\relax\else \@ifundefined{br@#2\@extra@b@citeb}{}{% - \@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi - \@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}% - \item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}\@biblabel{\NAT@num}% - \hyper@natanchorend]% - \NAT@ifcmd#1(@)(@)\@nil{#2}} + \@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}% + }% + \fi + \@ifundefined{b@#2\@extra@b@citeb}{% + \def\NAT@num{}% + }{% + \NAT@parse{#2}% + }% + \def\NAT@tmp{#1}% +% \end{macrocode} +% \changes{8.2}{2008 Jul 13}{(AO) Allow optional arguments preceding cite key.} +% We give meanings to \cs{bibitemOpen} and \cs{bibitemShut}; +% the default is \verb+\relax+. Special .bst files take care of inserting markup into +% the .bbl file. There, each \cs{bibitem} begins with \cs{BibitemOpen} and +% ends with \cs{BibitemShut}. +% \begin{macrocode} + \expandafter\let\expandafter\bibitemOpen\csname NAT@b@open@#2\endcsname + \expandafter\let\expandafter\bibitemShut\csname NAT@b@shut@#2\endcsname +% \end{macrocode} +% \changes{8.2}{2008 Jan 10}{(AO)Introduce \texttt{merge} package option} +% (AO) If this reference's |\cite| had been marked with a *, +% then it is to be merged into the previous reference, +% but only if this is not the first \verb+\bibitem+. +% +% We do Boolean algebra: if |\NAT@merge| > 1, and +% if this is not the first |\bibitem|, and +% if this citation key was starred, then +% perform the action delimited by the second set of braces below, otherwise the first set. +% \begin{macrocode} + \@ifnum{\NAT@merge>\@ne}{% + \NAT@bibitem@first@sw{% + \@firstoftwo + }{% + \@ifundefined{NAT@b*@#2}{% + \@firstoftwo + }{% + \expandafter\def\expandafter\NAT@num\expandafter{\the\c@NAT@ctr}% + \@secondoftwo + }% + }% + }{% + \@firstoftwo + }% +% \end{macrocode} +% The first set of braces will be executed (format an |\item|) unless the above test was satisfied. +% \changes{8.3}{2008 Nov 5}{(PWD) Correct code for when label is ok} +% \changes{8.3}{2008 Nov 5}{(PWD) Move incrementing of counter} +% \begin{macrocode} + {% + \global\advance\c@NAT@ctr\@ne + \@ifx{\NAT@tmp\@empty}{\@firstoftwo}{% + \@secondoftwo + }% + {% + \expandafter\def\expandafter\NAT@num\expandafter{\the\c@NAT@ctr}% + \global\NAT@stdbsttrue + }{}% + \bibitem@fin + \item[\hfil\NAT@anchor{#2}{\NAT@num}]% + \global\let\NAT@bibitem@first@sw\@secondoftwo + \NAT@bibitem@init + }% +% \end{macrocode} +% The second set of braces, executed when the test is satisfied. This does the +% merging with the previous entry. +% \begin{macrocode} + {% + \NAT@anchor{#2}{}% + \NAT@bibitem@cont + \bibitem@fin + }% % \end{macrocode} +% If working on an author-year styled entry, +% we tail out with |\NAT@ifcmd|, which subjects our arguments to further processing. +% Otherwise, we write out a very simple |\bibcite| command to the .aux file. +% \begin{macrocode} + \@ifx{\NAT@tmp\@empty}{% + \NAT@wrout{\the\c@NAT@ctr}{}{}{}{#2}% + }{% + \expandafter\NAT@ifcmd\NAT@tmp(@)(@)\@nil{#2}% + }% +}% +% \end{macrocode} +% % Note: in standard \LaTeX, the sequential list counter is printed directly % with |\item|, and then written to the auxiliary file so that |\cite| can % refer to it on the next run. Here, |\item| prints exactly the same thing % as |\cite| on the current run, if we are in numerical mode, otherwise % nothing. +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bibitem@fin} +% \begin{macro}{\NAT@bibitem@init} +% \begin{macro}{\NAT@bibitem@cont} +% The procedure \cs{bibitem@fin}, a dispatcher based on \cs{@bibstop}, +% completes the processing of the previous \cs{bibitem}, +% producing the needed punctuation. +% The other procedures are hooks, +% \cs{NAT@bibitem@init} executed if we are calling \cs{item}, +% and \cs{NAT@bibitem@cont} if we are not. +% \begin{macrocode} +\def\bibitem@fin{% + \@ifxundefined\@bibstop{}{\csname bibitem@\@bibstop\endcsname}% +}% +\def\NAT@bibitem@init{% + \let\@bibstop\@undefined +}% +\def\NAT@bibitem@cont{% + \let\bibitem@Stop\bibitemStop + \let\bibitem@NoStop\bibitemContinue +}% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\BibitemOpen} +% \begin{macro}{\BibitemShut} +% \begin{macro}{\bibitemStop} +% \begin{macro}{\bibitemNoStop} +% \begin{macro}{\bibitemContinue} +% \begin{macro}{\bibAnnote} +% \begin{macro}{\bibAnnoteFile} +% The markup that the special .bst puts into the .bbl file delimits each entry with +% \cs{BibitemOpen} and \cs{BibitemShut}, thereby giving us the means +% to insert text at the beginning and end of the entry. +% The latter command takes an argument, allowing Bib\TeX\ to tell us +% if the entry ended with a stop (period) or not. +% These punctuation procedures are defined here: +% \cs{bibitemStop} in the case where the entry ended with a stop, +% \cs{bibitemNoStop} if no stop, +% and the alternative \cs{bibitemContinue} if we are continuing the previous item. +% The latter two also assign the \cs{spacefactor} explicitly: we are at the end of +% a sentence. +% \begin{macrocode} +\def\BibitemOpen{% + \bibitemOpen +}% +\def\BibitemShut#1{% + \bibitemShut + \def\@bibstop{#1}% + \let\bibitem@Stop\bibitemStop + \let\bibitem@NoStop\bibitemNoStop +}% +\def\bibitemStop{}% +\def\bibitemNoStop{.\spacefactor\@mmm\space}% +\def\bibitemContinue{\spacefactor\@mmm\space}% +\mathchardef\@mmm=3000 % +\providecommand{\bibAnnote}[3]{% + \BibitemShut{#1}% + \def\@tempa{#3}\@ifx{\@tempa\@empty}{}{% + \begin{quotation}\noindent + \textsc{Key:}\ #2\\\textsc{Annotation:}\ \@tempa + \end{quotation}% + }% +}% +\providecommand{\bibAnnoteFile}[2]{% + \IfFileExists{#2}{% + \bibAnnote{#1}{#2}{\input{#2}}% + }{% + \bibAnnote{#1}{#2}{}% + }% +}% +\let\bibitemOpen\relax +\let\bibitemShut\relax +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bibfield} +% \begin{macro}{\@bibfield} +% \begin{macro}{\bibinfo} +% We provide a facility for handling the |\bibfield| markup in the .bbl file +% (that markup is generated by custom-bib styles that enable the \texttt{bibfield} guard code). +% The default semantics is to remember the content of the second argument so that it +% can be compared to the next instance of this class of |\bibfield| command. +% (In the case where references are being merged, that is, if |\NAT@merge| \(> 1\), +% and the present bib entry's key has been starred (*)). +% +% The outcome of comparing, say, the author field, is to execute one of two procedures, +% |\@bib@Xauthor| or |\@bib@Yauthor| with the content as the argument. +% +% If no special features have been enabled, these two procedures just |\relax| out, and the +% content is processed as usual. +% +% And if |elide| semantics are turned off, we do |\@secondoftwo|, which is the custom-bib default. +% +% Note that we take special measures when constructing the replacement part of the \TeX\ +% macro |\@tempa| (this will be remembered as the effective value of the field). +% If a |\Doi| markup command is encountered, we wish to ignore its first argument +% (which will be unique to the particular reference). +% +% We also define here the utility |\bibinfo| markup command of custom-bib +% (this markup is enabled by the \texttt{bibinfo} guard code). +% The procedure is a straightforward dispatcher to a macro whose name is +% based on the first argument to |\bibinfo|. For instance, |\bibinfo| |{foo}| +% will execute a procedure named |\bibinfo@X@foo|. +% If that name is undefined, the second argument of |\bibinfo| is simply expanded as is. +% If defined, the procedure should take a single argument, just like |\@firstofone| does. +% \begin{macrocode} +\def\bibfield{\@ifnum{\NAT@merge>\tw@}{\@bibfield}{\@secondoftwo}}% +\def\@bibfield#1#2{% + \begingroup + \let\Doi\@gobble + \let\bibinfo\relax + \let\restore@protect\@empty + \protected@edef\@tempa{#2}% + \aftergroup\def\aftergroup\@tempa + \expandafter\endgroup\expandafter{\@tempa}% + \expandafter\@ifx\expandafter{\csname @bib#1\endcsname\@tempa}{% + \expandafter\let\expandafter\@tempa\csname @bib@X#1\endcsname + }{% + \expandafter\let\csname @bib#1\endcsname\@tempa + \expandafter\let\expandafter\@tempa\csname @bib@Y#1\endcsname + }% + \@ifx{\@tempa\relax}{\let\@tempa\@firstofone}{}% + \@tempa{#2}% +}% +\def\bibinfo#1{% + \expandafter\let\expandafter\@tempa\csname bibinfo@X@#1\endcsname + \@ifx{\@tempa\relax}{\@firstofone}{\@tempa}% +}% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} % +% \begin{macro}{\NAT@bibitem@init} +% \begin{macro}{\@bib@Xauthor} +% \begin{macro}{\@bib@Xjournal} +% \begin{macro}{\@bibibid@} +% We now implement a scheme (just one out of many possible ones) for eliding repeated fields. +% +% If the author field matches, then that portion is elided, and if +% in addition the journal field matches, that portion is also elided. +% If the journal field matches and the author field does not, +% then the journal is replaced with \textit{ibid.} +% +% How it works: +% when the journal is processed by |\bibfield|, one of three possibilities will be at hand: +% \begin{enumerate} +% \item +% (the \texttt{journal} does not match) +% Here, the procedure |\@bib@Yjournal| is executed, but this control sequence name is undefined, +% so the second argument is expanded in place. +% \item +% (\texttt{journal} matchs but \texttt{author} does not) +% Here, |\bibinfo@X@journal| is set to |\@bib@Z@journal|, and the latter has its +% default meaning: +% the second argument of |\bibinfo| is replaced by \textit{ibid.}, +% \item +% (The \texttt{journal} matches and \texttt{author} also matches) +% In this case, |\bibinfo@X@journal| will be the same as |\@bib@Z@journal|, +% which has been set to |\@gobble|, +% so the second argument of |\bibinfo| is replaced by nothing. +% \end{enumerate} +% +% Adopters of \thestyle\ have the option of creating their own scheme +% and can even remove the present scheme by doing +% |\let| |\@bib@Xauthor| |\@undefined| and |\let| |\@bib@Xjournal| |\@undefined|. +% \begin{macrocode} +\def\@bib@Xauthor#1{\let\@bib@Xjournal\@gobble}% +\def\@bib@Xjournal#1{\begingroup\let\bibinfo@X@journal\@bib@Z@journal#1\endgroup}% +\def\@bibibid@#1{\textit{ibid}.}% +\appdef\NAT@bibitem@init{% + \let\@bibauthor \@empty + \let\@bibjournal \@empty + \let\@bib@Z@journal\@bibibid@ +}% +% \end{macrocode} +% +% Let us illustrate how eliding might be extended to the \texttt{year}. +% Two things need to be done: +% 1) define \cs{@bib@Xyear} to be \cs{@gobble}, and +% 2) append to \cs{NAT@bibitem@init} the code |\let| |\@bibyear| |\@empty|, thus: +% \begin{verbatim} +% \let\@bib@Xyear\@gobble +% \appdef\NAT@bibitem@init{\let\@bibyear\@empty}% +% \end{verbatim} +% However, the above fails to take into account what should happen if +% the year matches but the journal or author do not. +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\SK@lbibitem} % \changes{6.3}{1996 Jun 10}{Include \texttt{showkeys} coding if already % loaded} % \changes{6.4}{1996 Jun 27}{Remove from 2.09 coding} @@ -3831,21 +4675,47 @@ is read in after the main package file. \def\@lbibitem[#1]#2{% \SK@lbibitem[#1]{#2}\SK@\SK@@label{#2}\ignorespaces}\fi % \end{macrocode} -% \end{macro}\end{macro} +% \end{macro} % % \begin{macro}{\ifNAT@stdbst} % \changes{6.0}{1995 Sep 4}{Add flag} +% \changes{8.3}{2008 Nov 5}{Change autoswitch to numerical mode to include an error message} % If any non-author--year |\bibitem|s have been issued, then force % numerical mode, since the author--year |\bibitem|s can handle this, but -% the numerical ones cannot work in author--year mode. Do this by inserting -% |\NAT@numberstrue| in the auxiliary file. +% the numerical ones cannot work in author--year mode. +% Do this by setting |\NAT@stdbsttrue| when this is discovered (in |\@lbibitem|) +% and use this flag to write |\NAT@force@numbers| into the aux file. +% % \begin{macrocode} \newif\ifNAT@stdbst \NAT@stdbstfalse -\AtEndDocument - {\ifNAT@stdbst\if@filesw\immediate\write\@auxout{\string - \global\string\NAT@numberstrue}\fi\fi - } +\AtEndDocument{% + \ifNAT@stdbst\if@filesw + \immediate\write\@auxout{% + \string\providecommand\string\NAT@force@numbers{}% + \string\NAT@force@numbers + }% + \fi\fi + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NAT@force@numbers} +% \changes{8.3}{2008 Nov 5}{Add command to issue error message when numerical mode forced} +% This is written to the aux file when author--year citation cannot be supported. +% It is executed when the aux file is read in at the start of the next +% run. It prints an error message (warning is not enough, it may be ignored) +% and sets the numerical flag. +% \begin{macrocode} +\newcommand\NAT@force@numbers{% + \ifNAT@numbers\else + \PackageError{natbib}{Bibliography not compatible with author-year + citations.\MessageBreak + Press <return> to continue in numerical citation style} + {Check the bibliography entries for non-compliant syntax,\MessageBreak + or select author-year BibTeX style, e.g. plainnat}% + \global\NAT@numberstrue\fi} + % \end{macrocode} % \end{macro} % @@ -3867,17 +4737,26 @@ is read in after the main package file. % `references'.) % \begin{macrocode} \providecommand\bibcite{} -\renewcommand\bibcite[2]{\@ifundefined{b@#1\@extra@binfo}\relax - {\NAT@citemultiple - \PackageWarningNoLine{natbib}{Citation `#1' multiply defined}}% - \global\@namedef{b@#1\@extra@binfo}{#2}} +\renewcommand\bibcite[2]{% + \@ifundefined{b@#1\@extra@binfo}{\relax}{% + \NAT@citemultiple + \PackageWarningNoLine{natbib}{Citation `#1' multiply defined}% + }% + \global\@namedef{b@#1\@extra@binfo}{#2}% +}% \AtEndDocument{\NAT@swatrue\let\bibcite\NAT@testdef} \newcommand\NAT@testdef[2]{% - \def\NAT@temp{#2}\expandafter \ifx \csname b@#1\@extra@binfo\endcsname - \NAT@temp \else \ifNAT@swa \NAT@swafalse - \PackageWarningNoLine{natbib}{Citation(s) may have - changed.\MessageBreak - Rerun to get citations correct}\fi\fi} + \def\NAT@temp{#2}% + \expandafter \ifx \csname b@#1\@extra@binfo\endcsname\NAT@temp + \else + \ifNAT@swa \NAT@swafalse + \PackageWarningNoLine{natbib}{% + Citation(s) may have changed.\MessageBreak + Rerun to get citations correct% + }% + \fi + \fi +}% % \end{macrocode} % \end{macro} % @@ -3887,6 +4766,7 @@ is read in after the main package file. % \changes{5.3}{1994 Sep 13}{Full author list equals short list} % \changes{5.5}{1995 May 18}{Renamed from \cs{@citeapalk}} % \changes{6.0}{1995 Sep 4}{Recoded for version~6.0} +% \changes{8.3}{2008 Dec 3}{Remove additional increments of numerical counter} % If the argument of |\bibitem| contains no command, and if it does not % conform to the \thestyle{} syntax, then try the \texttt{apalike} % syntax (\emph{short}\texttt{, }\emph{year}). This has a funny template @@ -3897,11 +4777,14 @@ is read in after the main package file. % \begin{macrocode} %<*all|apalike|authordate> \newcommand\NAT@apalk{} -\def\NAT@apalk#1, #2, #3\@nil#4{\if\relax#2\relax - \global\NAT@stdbsttrue - \NAT@wrout{#1}{}{}{}{#4}\else - \stepcounter{NAT@ctr}% - \NAT@wrout{\arabic {NAT@ctr}}{#2}{#1}{}{#4}\fi} +\def\NAT@apalk#1, #2, #3\@nil#4{% + \if\relax#2\relax + \global\NAT@stdbsttrue + \NAT@wrout{#1}{}{}{}{#4}% + \else + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{}{#4}% + \fi +}% %</all|apalike|authordate> % \end{macrocode} % Note: the |NAT@ctr| is stepped here and everywhere else it is used, @@ -3927,31 +4810,38 @@ is read in after the main package file. % \begin{macro}{\citeauthoryear} % \changes{5.3}{1994 Sep 13}{Allow full authors in citation} % \changes{6.0}{1995 Sep 4}{Recode for version 6.0} +% \changes{8.3}{2008 Dec 3}{Remove additional increments of numerical counter} % For \texttt{newapa.bst} itself, the commands |\citestarts|, |\citeends|, % as well as |\betweenauthors| must be defined; for others in this group, % these commands are not needed. % \begin{macrocode} %<*newapa|chicago|all> \newcommand\citeauthoryear{} -\def\citeauthoryear#1#2#3(@)(@)\@nil#4{\stepcounter{NAT@ctr}\if\relax#3\relax - \NAT@wrout{\arabic {NAT@ctr}}{#2}{#1}{}{#4}\else - \NAT@wrout{\arabic {NAT@ctr}}{#3}{#2}{#1}{#4}\fi} -\newcommand\citestarts{\NAT@open} -\newcommand\citeends{\NAT@close} -\newcommand\betweenauthors{and} +\def\citeauthoryear#1#2#3(@)(@)\@nil#4{% + \if\relax#3\relax + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{}{#4}% + \else + \NAT@wrout{\the\c@NAT@ctr}{#3}{#2}{#1}{#4}% + \fi +}% +\newcommand\citestarts{\NAT@open}% +\newcommand\citeends{\NAT@close}% +\newcommand\betweenauthors{and}% %</newapa|chicago|all> % \end{macrocode} % \end{macro} % % \begin{macro}{\astroncite} % \changes{6.0}{1995 Sep 4}{Recode for version 6.0} +% \changes{8.3}{2008 Dec 3}{Remove additional increments of numerical counter} % The |\astroncite| command must similarly conform to |\NAT@bare| syntax % and put its arguments into the auxiliary file in the correct order. % \begin{macrocode} %<*astron|all> \newcommand\astroncite{} -\def\astroncite#1#2(@)(@)\@nil#3{\stepcounter{NAT@ctr}\NAT@wrout{\arabic -{NAT@ctr}}{#2}{#1}{}{#3}} +\def\astroncite#1#2(@)(@)\@nil#3{% + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{}{#3}% +}% %</astron|all> % \end{macrocode} % \end{macro} @@ -3982,9 +4872,13 @@ is read in after the main package file. % % \begin{macrocode} %<*harvard|all> -\newcommand\harvarditem[4][]% - {\if\relax#1\relax\bibitem[#2(#3)]{#4}\else - \bibitem[#1(#3)#2]{#4}\fi } +\newcommand\harvarditem[4][]{% + \if\relax#1\relax + \bibitem[#2(#3)]{#4}% + \else + \bibitem[#1(#3)#2]{#4}% + \fi +}% % \end{macrocode} % The command |\citeasnoun| must be defined since \texttt{harvard.bst} % can add it for cross-referencing. @@ -4025,7 +4919,7 @@ is read in after the main package file. % % \subsection{The Bibliography Listing} % Changes must be made to the \texttt{thebibliography} environment for -% author--year citations. This is done be defining the environment with the +% author--year citations. This is done by defining the environment with the % features common to both schemes, and then by invoking |\@bibsetup|, which % is either the author--year or numerical version. % @@ -4049,21 +4943,29 @@ is read in after the main package file. % % The packages of the KOMA scripts make use of |\bib@heading| which functions % much like |\bibsection|. If it is defined, let |\bibsection| be equal to it. +% \changes{8.2}{2008 Jul 02}{(AO) Employ \cs{@ifxundefined} for use on \cs{chapter}, \cs{NAT@sectionbib}, and \cs{bib@heading}.} +% \changes{8.3}{2008 Dec 5}{Restore \cs{@ifundefined} for \cs{chapter}, because of +% clashes with \texttt{chapterbib} package which also does this test} % \begin{macrocode} \providecommand\bibsection{} -\@ifundefined{chapter}% - {\renewcommand\bibsection{\section*{\refname - \@mkboth{\MakeUppercase{\refname}}{\MakeUppercase{\refname}}}}} - {\@ifundefined{NAT@sectionbib}% - {\renewcommand\bibsection{\chapter*{\bibname - \@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}}} - {\renewcommand\bibsection{\section*{\bibname - \ifx\@mkboth\@gobbletwo\else\markright{\MakeUppercase{\bibname}}\fi}}}} -\@ifclassloaded{amsart}% - {\renewcommand\bibsection{\section*{\refname}}}{} -\@ifclassloaded{amsbook}% - {\renewcommand\bibsection{\chapter*{\bibname}}}{} -\@ifundefined{bib@heading}{}{\let\bibsection\bib@heading} +\@ifundefined{chapter}{% + \renewcommand\bibsection{% + \section*{\refname\@mkboth{\MakeUppercase{\refname}}{\MakeUppercase{\refname}}}% + }% +}{% + \@ifxundefined\NAT@sectionbib{% + \renewcommand\bibsection{% + \chapter*{\bibname\@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}% + }% + }{% + \renewcommand\bibsection{% + \section*{\bibname\ifx\@mkboth\@gobbletwo\else\markright{\MakeUppercase{\bibname}}\fi}% + }% + }% +}% +\@ifclassloaded{amsart}{\renewcommand\bibsection{\section*{\refname}}}{}% +\@ifclassloaded{amsbook}{\renewcommand\bibsection{\chapter*{\bibname}}}{}% +\@ifxundefined\bib@heading{}{\let\bibsection\bib@heading}% % \end{macrocode} % \end{macro} % @@ -4105,19 +5007,27 @@ is read in after the main package file. % elsewhere with |\@listctr|, but now I refer to it explicitly. This is to % avoid trouble if |\@listctr| should ever disappear. (The value of % |\@listctr| is set by |\usecounter|.) +% +% \changes{8.2}{2008 Jan 10}{(AO)Introduce \texttt{merge} package option} +% We need to keep track of our state within the bibliography's list: +% |\NAT@bibitem@first@sw| will be true before the first |\item| command +% is executed, false thereafter. % \begin{macrocode} \newcounter{NAT@ctr} \renewenvironment{thebibliography}[1]{% - \bibsection\parindent \z@\bibpreamble\bibfont\list - {\@biblabel{\arabic{NAT@ctr}}}{\@bibsetup{#1}% - \setcounter{NAT@ctr}{0}}% - \ifNAT@openbib - \renewcommand\newblock{\par} - \else - \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}% - \fi - \sloppy\clubpenalty4000\widowpenalty4000 - \sfcode`\.=1000\relax + \bibsection + \parindent\z@ + \bibpreamble + \bibfont + \list{\@biblabel{\the\c@NAT@ctr}}{\@bibsetup{#1}\global\c@NAT@ctr\z@}% + \ifNAT@openbib + \renewcommand\newblock{\par}% + \else + \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}% + \fi + \sloppy\clubpenalty4000\widowpenalty4000 + \sfcode`\.\@m + \let\NAT@bibitem@first@sw\@firstoftwo % \end{macrocode} % The files \texttt{chicago.bst} and \texttt{named.bst} can add the % commands |\citeN| and |\shortcite| respectively to the \texttt{.bbl} @@ -4127,12 +5037,19 @@ is read in after the main package file. % \begin{macrocode} %<newapa|chicago|all> \let\citeN\cite \let\shortcite\cite %<harvard|all> \let\citeasnoun\cite - }{\def\@noitemerr{% - \PackageWarning{natbib} - {Empty `thebibliography' environment}}% - \endlist\vskip-\lastskip} - \let\bibfont\relax -\let\bibpreamble\relax +}{% + \bibitem@fin + \bibpostamble + \def\@noitemerr{% + \PackageWarning{natbib}{Empty `thebibliography' environment}% + }% + \endlist + \bibcleanup +}% +\let\bibfont\@empty +\let\bibpreamble\@empty +\let\bibpostamble\@empty +\def\bibcleanup{\vskip-\lastskip}% % \end{macrocode} % \end{environment} % @@ -4221,6 +5138,8 @@ is read in after the main package file. % \end{macrocode} % \end{macro}\end{macro} % +% \begin{macro}{\NAT@anchor} +% A general hypertext tool, \cs{NAT@anchor}, is defined right here. % \begin{macro}{\hyper@natanchorstart} % \changes{6.4}{1996 Oct 2}{Provide macro for \texttt{hyperref} package} % \begin{macro}{\hyper@natanchorend} @@ -4246,84 +5165,72 @@ is read in after the main package file. % % The |\hyper@natlinkbreak| to designed to break links between the names and % date, avoiding some possible problems when links go over a page. +% % \begin{macrocode} -\providecommand\hyper@natanchorstart[1]{} -\providecommand\hyper@natanchorend{} -\providecommand\hyper@natlinkstart[1]{} -\providecommand\hyper@natlinkend{} -\providecommand\hyper@natlinkbreak[2]{#1} +\def\NAT@anchor#1#2{% + \hyper@natanchorstart{#1\@extra@b@citeb}% + \def\@tempa{#2}\@ifx{\@tempa\@empty}{}{\@biblabel{#2}}% + \hyper@natanchorend +}% +\providecommand\hyper@natanchorstart[1]{}% +\providecommand\hyper@natanchorend{}% +\providecommand\hyper@natlinkstart[1]{}% +\providecommand\hyper@natlinkend{}% +\providecommand\hyper@natlinkbreak[2]{#1}% % \end{macrocode} -% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \changes{6.7}{1997 Nov 10}{Accommodate \texttt{babel}'s redefinitions} % \changes{6.9}{1999 Feb 26}{Include \texttt{babel} accommodation with % \texttt{subpack}} % \changes{6.9a}{1999 Apr 20}{Fixes for \texttt{babel} 3.6t} +% \changes{8.3}{2008 Aug 28}{Redo the \texttt{babel} accommodations} % The \texttt{babel} bundle redefines several internal commands in order to -% handle special active characters required by some languages. One of these -% redefined commands is |\@citex|. This fails for \thestyle\ for two -% reasons: the syntax is different and the \thestyle\ definition of |\@citex| -% has not yet been finalized. I correct this doing \texttt{babel}'s -% redefinition at the |\begin{document}| with the right syntax. -% -% The main purpose of these redefinitions is to allow special active characters -% to appear in the citation keys. To this end, |\@citex|, |\bibcite|, -% |\nocite|, |\@bibitem|, and |\@lbibitem| need changing such that the active -% characters are turned off when the keys are processed. In the case of -% |\bibcite|, which is only ever called in a context where the active -% characters are turned off, the second argument, the actual label, has the -% active characters temporarily turned on. This causes \thestyle\ to crash; -% hence \texttt{babel} now checks (v3.6t) for \thestyle\ and keeps the original -% definition. This means any active characters in the \thestyle\ labels will -% not be processed correctly, but these special characters should never be here -% anyway, since they violate portability. -% -% It is also necessary to redefine |\NAT@testdef| which also uses the keys as -% arguments. (It is a replacement for |\bibcite| for when the \texttt{.aux} -% file is read in at the end.) Furthermore, |\@lbibitem| needs redefining, but -% \texttt{babel} does not (yet) do this, only |\@bibitem|. -% -% Strictly speaking, \thestyle\ should be loaded before \texttt{babel} so that -% the latter saves and modifies the \thestyle\ definitions, and not the -% standard \LaTeX\ ones. However, in reality this is not necessary since -% |\bibcite| is not redefined with \thestyle\ and |\@citex| is redefined by -% \thestyle\ itself after the preamble. However, |\nocite| and |\@lbibitem| can -% cause problems with the ordering. Solve this by redefining them immediately -% if \texttt{babel} is present (i.e., \texttt{babel} before \thestyle); in this -% case, \texttt{babel} has previously redefined them wrongly, \thestyle\ then -% creates its own base definitions, and the \texttt{babel} redefinition is now -% carried out again, with the proper ``originals''. A complication comes with -% |\@lbibitem| in that at present \texttt{babel} does not redefine it, so it -% must be (conditionally) added to the |\AtBeginDocument| hook in case -% \thestyle\ is loaded first. If \texttt{babel} is changed in future, this -% addition will not be needed and will not be executed. Thus the order of the -% two packages is unimportant. -% -% Note: all this redefining is only important if there are keys containing -% active characters. One point to note is that optional notes containing active -% characters will not work right for \texttt{babel}, neither with or -% without \thestyle. They will work with the \texttt{german} package, but then -% the keys with active characters will not. Oh boy! +% handle special active characters required by some languages. +% The purpose of these redefinitions is to allow special active characters +% to appear in the citation keys; one good example is the colon which +% becomes active with the \texttt{french} option. +% The redefined commands are: |\@bibitem|, |\nocite|, |\bibcite|, and |\@citex|. +% The first is not used at all by \thestyle, which uses only |\@lbibitem| instead. +% +% But \texttt{babel} does special things for \thestyle: the |\bibcite| definition is left +% unchanged, and |\@citex| is changed to account for the different syntax under +% \thestyle. However, the way \texttt{babel} alters the \thestyle\ |\@citex| +% relies on \thestyle\ doing the same thing; this is to make the order of loading the +% packages unimportant. It is rather confusing situation. +% +% As of version~8.3 of \thestyle, we do things better. The necessary switches +% |\@safe@activestrue| and |\@safe@activesfalse| are put around all expansions +% of the citation keys, making the \thestyle\ commands immediately compatible +% with \texttt{babel}; no redefinitions are necessary. However, since \texttt{babel} +% (at least up to version 3.8l of 2008/03/16) redefines |\@citex| in a way that +% relies on \thestyle\ having already done it too (more precisely, it relies +% on \thestyle\ having already defined |\org@@citex| as the original +% definition) this step must be preserved in \thestyle. It does no harm. +% +% It is also necessary to define dummy |\@safe@actives...| in case \texttt{babel} +% is not included. Do this when \thestyle\ is loaded, not at |\begin{doc}|; +% \texttt{babel} overwrites with |\def| so order with \thestyle\ is not important; +% however, \texttt{chapterbib} issues |\nocite{*}| when loaded, and this causes +% problems if these are not already defined. +% +% \changes{8.2}{2008 Jul 02}{(AO) Employ \cs{@ifxundefined} for use on \cs{bbl@redefine}.} % % \begin{macrocode} -\@ifundefined{bbl@redefine}{}{% - \bbl@redefine\nocite#1{% - \@safe@activestrue\org@nocite{#1}\@safe@activesfalse}% -\bbl@redefine\@lbibitem[#1]#2{% - \@safe@activestrue\org@@lbibitem[#1]{#2}\@safe@activesfalse}% -} -\AtBeginDocument{\@ifundefined{bbl@redefine}{}{% -\bbl@redefine\@citex[#1][#2]#3{% - \@safe@activestrue\org@@citex[#1][#2]{#3}\@safe@activesfalse}% -\bbl@redefine\NAT@testdef#1#2{% - \@safe@activestrue\org@NAT@testdef{#1}{#2}\@safe@activesfalse}% -\@ifundefined{org@@lbibitem}{% -\bbl@redefine\@lbibitem[#1]#2{% - \@safe@activestrue\org@@lbibitem[#1]{#2}\@safe@activesfalse}}{}% -}} +\AtBeginDocument{% + \@ifpackageloaded{babel}{% + \let\org@@citex\@citex}{}} +\providecommand\@safe@activestrue{}% +\providecommand\@safe@activesfalse{}% + % \end{macrocode} % -% \subsection{Sorting and Compression of Numbers} +% \subsection{Sorting, Compressing, and Merging of Numbers} % The \texttt{cite} and (obsolete) \texttt{citesort} packages by Donald % Arseneau provide the coding for printing multiple citation numbers in % ascending order, and with a range where applicable. That is, if the @@ -4342,6 +5249,149 @@ is read in after the main package file. % \texttt{sort} and \texttt{sort\&compress}. % % \begin{macro}{\NAT@sort@cites} +% \changes{8.2}{2008 Jan 10}{(AO)Various changes to \texttt{NAT@sort@cites} and friends} +% \changes{8.2}{2008 Jul 12}{(AO) Do not write .aux file entries in \cs{NAT@citexnum} or \cs{NAT@citex}; +% do this in \cs{NAT@sort@cites} where the keys will be in the user's order.} +% +% |\NAT@sort@cites| has been taken over so that we can preprocess the +% citation keys with |\NAT@star@cite|, +% where |\NAT@cite@list| is created as a side effect. +% Afterwards, if |\NAT@sort| is greater than zero, the list is sorted with |\NAT@sort@cites@|. +% +% \begin{macrocode} +\newcommand\NAT@sort@cites[1]{% + \let\NAT@cite@list\@empty + \@for\@citeb:=#1\do{\expandafter\NAT@star@cite\@citeb\@@}% + \if@filesw + \expandafter\immediate\expandafter\write\expandafter\@auxout + \expandafter{\expandafter\string\expandafter\citation\expandafter{\NAT@cite@list}}% + \fi + \@ifnum{\NAT@sort>\z@}{% + \expandafter\NAT@sort@cites@\expandafter{\NAT@cite@list}% + }{}% +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NAT@star@cite} +% \begin{macro}{\NAT@star@cite@star} +% \begin{macro}{\NAT@star@cite@nostar} +% \begin{macro}{\NAT@star@cite@pre} +% \begin{macro}{\NAT@star@cite@post} +% \changes{8.2}{2008 Jan 10}{(AO)Various changes to \texttt{NAT@sort@cites} and friends} +% +% With package option |merge| in effect, +% the |\NAT@star@cite| procedure determines if the optional * character +% has been prepended to the citation key, and strips it. +% (If so, we define a macro that later (in |thebibliography|) flags this fact, +% allowing us to merge that reference back with the previous reference, under +% a single number.) +% The citation key is then appended to |\NAT@cite@list|. +% +% If |\NAT@merge|\({}=1\), the only processing done: +% the * is recognized as part of the |merge| syntax. +% +% \textbf{Caveat:} the citation key is chosen by the user, and there is no rule saying +% that the * character must not appear in the key. So, if the user has chosen a key +% that begins with the * character, she will get unexpected results +% (undefined citation, for one). +% The best we can do for her is allow the user to turn off this processing step, +% which they will want to do if they are being confounded: remove the |merge| package option. +% +% A problem arises when keys are being sorted, because a key marked with a * could conceivably +% move away from the key it was intended to be merged with. +% The solution is for the user to proceed by deliberate steps: +% first, select all the references and citations with sorting turned off |\NAT@sort|${}=0$, +% then, second, turn on sorting and merge together. +% +% \changes{8.2}{2008 Jul 13}{(AO) Allow optional arguments preceding cite key.} +% A second syntactical extension provided by \thestyle\ pertains to the key itself: +% within the argument of \verb+\cite+, a cite key may be preceded by two optional arguements, e.g., +% \verb+\cite[+\emph{pre}\verb+]+\verb+[+\emph{post}\verb+]{+\emph{key}\verb+}+, +% where \emph{pre} represents text to be prepended to the reference (\verb+\bibitem+ content), +% with \emph{post} appended thereto. +% +% Thus it is possible for the user to mark up the document: +% \begin{verbatim} +% text \cite{*[{See, e.g., }][ for a facile explanation]ablebaker} +% \end{verbatim} +% The above example illustrates the use of the star-form and both optional arguments. +% +% \textbf{Caveat:} Because the comma (,) character is part of the syntax of \verb+\cite+, +% and because the bracket delimiters ([]) are not first-class delimiters in the eyes of \TeX, +% you must enclose the optional argument in braces (\verb+{}+) if a comma is present in the +% argument (that goes for brackets, too, of course). +% +% The five procedures defined here are solely for the purpose of parsing the star (*) and +% the two optional arguments, followed by the usual cite key. +% \begin{macrocode} +\def\NAT@star@cite{% + \let\NAT@star@sw\@secondoftwo + \@ifnum{\NAT@merge>\z@}{% + \@ifnextchar*{% + \let\NAT@star@sw\@firstoftwo + \NAT@star@cite@star + }{% + \NAT@star@cite@nostar + }% + }{% + \NAT@star@cite@nostar + }% +}% +\def\NAT@star@cite@star*{% + \NAT@star@cite@nostar +}% +\def\NAT@star@cite@nostar{% + \let\nat@keyopt@open\@empty + \let\nat@keyopt@shut\@empty + \@ifnextchar[{\NAT@star@cite@pre}{\NAT@star@cite@pre[]}% +}% +\def\NAT@star@cite@pre[#1]{% + \def\nat@keyopt@open{#1}% + \@ifnextchar[{\NAT@star@cite@post}{\NAT@star@cite@post[]}% +}% +\def\NAT@star@cite@post[#1]#2\@@{% + \def\nat@keyopt@shut{#1}% + \NAT@star@sw{\expandafter\global\expandafter\let\csname NAT@b*@#2\endcsname\@empty}{}% + \NAT@cite@list@append{#2}% +}% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NAT@cite@list@append} +% |\NAT@cite@list@append{bar}| +% appends |bar| to the replacement part of |\NAT@cite@list| (without any expansion of |bar|). +% We separate the entries with a comma (,). +% +% \begin{macrocode} +\def\NAT@cite@list@append#1{% + \edef\@citeb{\@firstofone#1\@empty}% + \if@filesw\@ifxundefined\@cprwrite{}{\expandafter\@cprwrite\@citeb=}\fi + \if\relax\nat@keyopt@open\relax\else + \global\expandafter\let\csname NAT@b@open@\@citeb\endcsname\nat@keyopt@open + \fi + \if\relax\nat@keyopt@shut\relax\else + \global\expandafter\let\csname NAT@b@shut@\@citeb\endcsname\nat@keyopt@shut + \fi + \toks@\expandafter{\NAT@cite@list}% + \ifx\NAT@cite@list\@empty + \@temptokena\expandafter{\@citeb}% + \else + \@temptokena\expandafter{\expandafter,\@citeb}% + \fi + \edef\NAT@cite@list{\the\toks@\the\@temptokena}% +}% +% \end{macrocode} +% Now that we have |\NAT@appdef|, it would be beneficial to apply it to +% the workings of |\NAT@sort@cites@| and |\NAT@make@cite@list|: +% a whole lot of those nasty |\protected@edef|s would evaporate! +% \end{macro} +% +% \begin{macro}{\NAT@sort@cites@} % \changes{6.4}{1996 Oct 11}{Add coding from \texttt{cite.sty}} % \changes{6.6}{1997 Jun 3}{Redo to sort cite keys; works with author--year % mode} @@ -4350,7 +5400,7 @@ is read in after the main package file. % for no sorting; 1 for sorting; compression (numerical mode only) is % controlled with |\NAT@cmprs| being 0 (off) and 1 (on). % -% The macro |\NAT@sort@cites| places the reordered list of citation keys (the +% The macro |\NAT@sort@cites@| places the reordered list of citation keys (the % argument to |\cite|\textit{xxx}) in |\NAT@cite@list|. If sorting is turned % off, this list is the same as the input. % @@ -4360,82 +5410,161 @@ is read in after the main package file. % |\NAT@num|, these are added to |\NAT@nonsort@list|, which is appended at the % end to the main list. Finally, the trailing comma is removed with % |\NAT@xcom|. +% +% Algorithm note (AO): aside from an optimization for inserting a trailing key, +% the sort algorithm performs a linear search through the +% partial list of sorted keys each time a new key is inserted, thereby +% executing $O(n^2)$ key comparisons for an $n$-key list. +% +% \changes{8.2}{2008 Jan 10}{(AO)Various changes to \texttt{NAT@sort@cites} and friends} +% \changes{8.2}{2008 Jan 10}{(AO) The sort algorithm had not been stable; fixed.} +% \changes{8.2}{2008 Jul 16}{(AO) Protect against empty argument.} +% This procedure used to be known as |\NAT@sort@cites|. +% It is now called by |\NAT@sort@cites| if |\NAT@sort| is positive. +% Note that compiling |\NAT@cite@list| has already been taken care of by |\NAT@star@cite|. +% We are using the Plain \TeX\ count register |\count@| to calculate how many citations +% there will be (but we do not get the right answer if \texttt{compress} is in effect). +% % \begin{macrocode} -\ifnum\NAT@sort>0 -\newcommand\NAT@sort@cites[1]{% -\@tempcntb\m@ne -\let\@celt\delimiter -\def\NAT@num@list{}% -\def\NAT@cite@list{}% -\def\NAT@nonsort@list{}% -\@for \@citeb:=#1\do{\NAT@make@cite@list}% -\protected@edef\NAT@cite@list{\NAT@cite@list\NAT@nonsort@list}% -\protected@edef\NAT@cite@list{\expandafter\NAT@xcom\NAT@cite@list @@}} +\newcommand\NAT@sort@cites@[1]{% + \count@\z@ + \@tempcntb\m@ne + \let\@celt\delimiter + \def\NAT@num@list{}% + \let\NAT@cite@list\@empty + \let\NAT@nonsort@list\@empty + \@for \@citeb:=#1\do{\NAT@make@cite@list}% + \ifx\NAT@nonsort@list\@empty\else + \protected@edef\NAT@cite@list{\NAT@cite@list\NAT@nonsort@list}% + \fi + \ifx\NAT@cite@list\@empty\else + \protected@edef\NAT@cite@list{\expandafter\NAT@xcom\NAT@cite@list @@}% + \fi +}% % \end{macrocode} +% \end{macro} +% % \begin{macro}{\NAT@make@cite@list} +% Work by side effect: add to \cmd\NAT@cite@list\ or \cmd\NAT@nonsort@list. % This is essentially Arseneau's coding, with some renaming and the addition -% of |\NAT@cite@list| for the citation keys. The trick with the catcode is -% his, and it determines if |\NAT@num| is really a number. This is a +% of |\NAT@cite@list| for the citation keys. The trick |\NAT@ifcat@num| does is his: +% it determines if |\NAT@num| is really a number. This is a % non-number if the optional argument to |\bibitem| does not conform to any % of the allowed \thestyle\ syntaxes, such as if \texttt{alph.bst} is used. +% +% Note that in the expanded definitions of |\NAT@num@list|, the token |\celt| remains unexpanded. +% +% \changes{8.2}{2008 Jan 10}{(AO)Various changes to \texttt{NAT@sort@cites} and friends} +% \changes{8.2}{2008 Jun 26}{(AO)Employ \cs{NAT@ifcat@num} to make the test on \cs{NAT@num}} +% Made the sort a stable sort. % \begin{macrocode} -\begingroup \catcode`\_=8 -\gdef\NAT@make@cite@list{% - \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% - \@ifundefined{b@\@citeb\@extra@b@citeb}{\def\NAT@num{A}}% - {\NAT@parse{\@citeb}}% - \ifcat _\ifnum\z@<0\NAT@num _\else A\fi - \@tempcnta\NAT@num \relax +\def\NAT@make@cite@list{% + \advance\count@\@ne + \@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse + \@ifundefined{b@\@citeb\@extra@b@citeb}% + {\def\NAT@num{A}}% + {\NAT@parse{\@citeb}}% + \NAT@ifcat@num\NAT@num + {\@tempcnta\NAT@num \relax % \end{macrocode} -% If highest number so far, add at the end. +% If less than the highest number so far, +% process the numerical list to insert number and citation key. % \begin{macrocode} - \ifnum \@tempcnta>\@tempcntb - \protected@edef\NAT@num@list{\NAT@num@list \@celt{\NAT@num}}% - \protected@edef\NAT@cite@list{\NAT@cite@list\@citeb,}% - \@tempcntb\@tempcnta - \else + \@ifnum{\@tempcnta<\@tempcntb}{% + \let\NAT@@cite@list=\NAT@cite@list + \let\NAT@cite@list\@empty + \begingroup\let\@celt=\NAT@celt\NAT@num@list\endgroup + \protected@edef\NAT@num@list{% + \expandafter\NAT@num@celt \NAT@num@list \@gobble @% + }% % \end{macrocode} -% Else, process the numerical list to insert number and citation key. +% Else append. Stable sort is achieved when a duplicate high value appears. % \begin{macrocode} - \let\NAT@@cite@list=\NAT@cite@list \def\NAT@cite@list{}% - \protected@edef\NAT@num@list{\expandafter\NAT@num@celt \NAT@num@list \@gobble @}% - {\let\@celt=\NAT@celt\NAT@num@list}% - \fi - \else + }{% + \protected@edef\NAT@num@list{\NAT@num@list \@celt{\NAT@num}}% + \protected@edef\NAT@cite@list{\NAT@cite@list\@citeb,}% + \@tempcntb\@tempcnta + }% % \end{macrocode} % If not a number, add it to |\NAT@nonsort@list|. % \begin{macrocode} - \protected@edef\NAT@nonsort@list{\NAT@nonsort@list\@citeb,}% - \fi} -\endgroup + }% + {\protected@edef\NAT@nonsort@list{\NAT@nonsort@list\@citeb,}}% +}% % \end{macrocode} % \end{macro} -% This is the macro to insert a new key into the key list. All the keys so -% far are first stored in |\NAT@@cite@list| and transferred over to -% |\NAT@cite@list|, with the new key inserted where appropriate. The macros -% |\NAT@nextc| and |\NAT@restc| return the next entry in the list, or the +% +% \begin{macro}{\NAT@celt} +% Possibly insert a new key into the current position in the key list |\NAT@cite@list|. +% \changes{8.2}{2008 Jan 10}{(AO)Various changes to \texttt{NAT@sort@cites} and friends} +% Made the sort a stable sort. +% +% This procedure is run against each successive position in the key list |\NAT@num@list|, +% initially with |\NAT@cite@list| empty and |\NAT@@cite@list| holding the original key list. +% +% \begin{macrocode} +\def\NAT@celt#1{% +% \end{macrocode} +% If the new key is lower than the current key, then insert the key. +% The assignment |\let\@celt| has the effect of traversing the remained of the list with a no-op. +% \begin{macrocode} + \@ifnum{#1>\@tempcnta}{% + \xdef\NAT@cite@list{\NAT@cite@list\@citeb,\NAT@@cite@list}% + \let\@celt\@gobble +% \end{macrocode} +% Pop |\NAT@@cite@list|, appending to |\NAT@cite@list|, and continue the traversal of the list. +% \begin{macrocode} + }{% + \expandafter\def@NAT@cite@lists\NAT@@cite@list\@@ + }% +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NAT@num@celt} +% Insert a new number into the number list. +% The trio of |\expandafter|s result in |\NAT@num@celt| tailing on, thus forming a loop. +% \changes{8.2}{2008 Jan 10}{(AO)Various changes to \texttt{NAT@sort@cites} and friends} +% Made the sort a stable sort. +% \begin{macrocode} +\def\NAT@num@celt#1#2{% + \ifx#1\@celt + \@ifnum{#2>\@tempcnta}{% + \@celt{\number\@tempcnta}% + \@celt{#2}% + }{% + \@celt{#2}% + \expandafter\NAT@num@celt + }% + \fi +}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\def@NAT@cite@lists} +% \begin{macro}{\NAT@nextc} +% \begin{macro}{\NAT@restc} +% \begin{macro}{\NAT@xcom} +% The procedure |\def@NAT@cite@lists| effectively +% removes the first element of |\NAT@@cite@list| and appends it to |\NAT@cite@list|. +% The macros |\NAT@nextc| and |\NAT@restc| return the next entry in the list, and the % rest of the list without the first entry, respectively. +% (AO: in lisp terminology, |\NAT@nextc| is car, |\NAT@restc| is cdr.) % \begin{macrocode} -\def\NAT@celt#1{\ifnum #1<\@tempcnta - \xdef\NAT@cite@list{\NAT@cite@list\expandafter\NAT@nextc\NAT@@cite@list @@}% - \xdef\NAT@@cite@list{\expandafter\NAT@restc\NAT@@cite@list}% - \else - \xdef\NAT@cite@list{\NAT@cite@list\@citeb,\NAT@@cite@list}\let\@celt\@gobble% - \fi} -\def\NAT@num@celt#1#2{\ifx \@celt #1% - \ifnum #2<\@tempcnta - \@celt{#2}% - \expandafter\expandafter\expandafter\NAT@num@celt - \else - \@celt{\number\@tempcnta}\@celt{#2}% - \fi\fi} +\def\def@NAT@cite@lists#1,#2\@@{% + \xdef\NAT@cite@list{\NAT@cite@list#1,}% + \xdef\NAT@@cite@list{#2}% +}% \def\NAT@nextc#1,#2@@{#1,} \def\NAT@restc#1,#2{#2} \def\NAT@xcom#1,@@{#1} -\else - \newcommand\NAT@sort@cites[1]{\protected@edef\NAT@cite@list{#1}}\fi % \end{macrocode} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \subsection{Local Configuration} % \changes{5.2}{1994 Aug 25}{Add reading in of \texttt{natbib.cfg}} diff --git a/Master/texmf-dist/source/latex/natbib/natbib.ins b/Master/texmf-dist/source/latex/natbib/natbib.ins index 14f4c8380ae..bba3026fc85 100644 --- a/Master/texmf-dist/source/latex/natbib/natbib.ins +++ b/Master/texmf-dist/source/latex/natbib/natbib.ins @@ -1,5 +1,5 @@ % File: natbib.ins -% Copyright 2006 Patrick W. Daly +% Copyright 2009 Patrick W. Daly % % This is the natbib installation file for extracting package and driver % files from the original source file. Simply process it under @@ -73,15 +73,15 @@ End of documentation driver file. \askforoverwritefalse \generate{\file{natbib.sty}{\from{natbib.dtx}{package,all}} - \file{natnotes}{\usepreamble\refsheet\usepostamble\refsheetq + \file{natnotes.tex}{\usepreamble\refsheet\usepostamble\refsheetq \from{natbib.dtx}{notes}} - \file{natbib.drv}{\usepreamble\driver\usepostamble\driverq + \file{natbib.ltx}{\usepreamble\driver\usepostamble\driverq \from{natbib.dtx}{driver}} } \obeyspaces \Msg{*********************************************}% \Msg{* For documentation, process natbib.dtx *}% -\Msg{* or the driver file natbib.drv *}% +\Msg{* or the driver file natbib.ltx *}% \Msg{* For reference sheet, process natnotes.tex *} \Msg{*********************************************} diff --git a/Master/texmf-dist/tex/latex/natbib/natbib.sty b/Master/texmf-dist/tex/latex/natbib/natbib.sty index 173e896c34f..eec93eb6e7f 100644 --- a/Master/texmf-dist/tex/latex/natbib/natbib.sty +++ b/Master/texmf-dist/tex/latex/natbib/natbib.sty @@ -19,7 +19,7 @@ %% Full documentation can be obtained by LaTeXing that original file. %% Only a few abbreviated comments remain here to describe the usage. %% ============================================= -%% Copyright 1993-2007 Patrick W Daly +%% Copyright 1993-2009 Patrick W Daly %% Max-Planck-Institut f\"ur Sonnensystemforschung %% Max-Planck-Str. 2 %% D-37191 Katlenburg-Lindau @@ -27,7 +27,8 @@ %% E-mail: daly@mps.mpg.de \NeedsTeXFormat{LaTeX2e}[1995/06/01] \ProvidesPackage{natbib} - [2007/10/30 8.1 (PWD)] + [2009/02/02 8.3 (PWD, AO)] + % This package reimplements the LaTeX \cite command to be used for various % citation styles, both author-year and numerical. It accepts BibTeX % output intended for many other packages, and therefore acts as a @@ -140,18 +141,41 @@ % compress - compresses without sorting % longnamesfirst - makes first citation full author list % sectionbib - puts bibliography in a \section* instead of \chapter* + % merge - allows the citation key to have a * prefix, + % signifying to merge its reference with that of the previous citation. + % elide - if references are merged, repeated portions of later ones may be removed. + % mcite - recognizes and ignores the * prefix for merging. % Punctuation so selected dominates over any predefined ones. % Package options are called as, e.g. % \usepackage[square,comma]{natbib} % LaTeX the source file natbib.dtx to obtain more details % or the file natnotes.tex for a brief reference sheet. %----------------------------------------------------------- +\providecommand\@ifxundefined[1]{% + \ifx#1\@undefined\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +}% +\providecommand\@ifnum[1]{% + \ifnum#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +}% +\providecommand\@ifx[1]{% + \ifx#1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi +}% +\providecommand\appdef[2]{% + \toks@\expandafter{#1}\@temptokena{#2}% + \edef#1{\the\toks@\the\@temptokena}% +}% \@ifclassloaded{agu2001}{\PackageError{natbib} {The agu2001 class already includes natbib coding,\MessageBreak so you should not add it explicitly} {Type <Return> for now, but then later remove\MessageBreak the command \protect\usepackage{natbib} from the document} \endinput}{} +\@ifclassloaded{agutex}{\PackageError{natbib} + {The AGUTeX class already includes natbib coding,\MessageBreak + so you should not add it explicitly} + {Type <Return> for now, but then later remove\MessageBreak + the command \protect\usepackage{natbib} from the document} + \endinput}{} \@ifclassloaded{aguplus}{\PackageError{natbib} {The aguplus class already includes natbib coding,\MessageBreak so you should not add it explicitly} @@ -210,6 +234,7 @@ \let\bibstyle@unsrtnat=\bibstyle@plainnat \newif\ifNAT@numbers \NAT@numbersfalse \newif\ifNAT@super \NAT@superfalse +\let\NAT@merge\z@ \DeclareOption{numbers}{\NAT@numberstrue \ExecuteOptions{square,comma,nobibstyle}} \DeclareOption{super}{\NAT@supertrue\NAT@numberstrue @@ -239,14 +264,20 @@ \newif\ifNAT@openbib \NAT@openbibfalse \DeclareOption{openbib}{\NAT@openbibtrue} \DeclareOption{sectionbib}{\def\NAT@sectionbib{on}} -\def\NAT@sort{0} -\def\NAT@cmprs{0} -\DeclareOption{sort}{\def\NAT@sort{1}} -\DeclareOption{compress}{\def\NAT@cmprs{1}} -\DeclareOption{sort&compress}{\def\NAT@sort{1}\def\NAT@cmprs{1}} +\def\NAT@sort{\z@} +\def\NAT@cmprs{\z@} +\DeclareOption{sort}{\def\NAT@sort{\@ne}} +\DeclareOption{compress}{\def\NAT@cmprs{\@ne}} +\DeclareOption{sort&compress}{\def\NAT@sort{\@ne}\def\NAT@cmprs{\@ne}} +\DeclareOption{mcite}{\let\NAT@merge\@ne} +\DeclareOption{merge}{\@ifnum{\NAT@merge<\tw@}{\let\NAT@merge\tw@}{}} +\DeclareOption{elide}{\@ifnum{\NAT@merge<\thr@@}{\let\NAT@merge\thr@@}{}} \@ifpackageloaded{cite}{\PackageWarningNoLine{natbib} {The `cite' package should not be used\MessageBreak with natbib. Use option `sort' instead}\ExecuteOptions{sort}}{} +\@ifpackageloaded{mcite}{\PackageWarningNoLine{natbib} + {The `mcite' package should not be used\MessageBreak + with natbib. Use option `merge' instead}\ExecuteOptions{merge}}{} \@ifpackageloaded{citeref}{\PackageError{natbib} {The `citeref' package must be loaded after natbib}% {Move \protect\usepackage{citeref} to after \string\usepackage{natbib}}}{} @@ -254,8 +285,7 @@ \DeclareOption{longnamesfirst}{\NAT@longnamestrue} \DeclareOption{nonamebreak}{\def\NAT@nmfmt#1{\mbox{\NAT@up#1}}} \def\NAT@nmfmt#1{{\NAT@up#1}} -\renewcommand\bibstyle[1]{\@ifundefined{bibstyle@#1}{\relax} - {\csname bibstyle@#1\endcsname}} +\renewcommand\bibstyle[1]{\csname bibstyle@#1\endcsname} \AtBeginDocument{\global\let\bibstyle=\@gobble} \let\@citestyle\bibstyle \newcommand\citestyle[1]{\@citestyle{#1}\let\bibstyle\@gobble} @@ -321,29 +351,36 @@ \newcommand\NAT@aysep{,} \newcommand\NAT@yrsep{,} \newcommand\NAT@cmt{, } \newcommand\NAT@cite% - [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\ \fi + [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi #1\if*#3*\else\NAT@cmt#3\fi\NAT@@close\else#1\fi\endgroup} \newcommand\NAT@citenum% - [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\ \fi + [3]{\ifNAT@swa\NAT@@open\if*#2*\else#2\NAT@spacechar\fi #1\if*#3*\else\NAT@cmt#3\fi\NAT@@close\else#1\fi\endgroup} \newcommand\NAT@citesuper[3]{\ifNAT@swa -\if*#2*\else#2\ \fi +\if*#2*\else#2\NAT@spacechar\fi \unskip\kern\p@\textsuperscript{\NAT@@open#1\NAT@@close}% - \if*#3*\else\ #3\fi\else #1\fi\endgroup} + \if*#3*\else\NAT@spacechar#3\fi\else #1\fi\endgroup} \providecommand\textsuperscript[1]{\mbox{$^{\mbox{\scriptsize#1}}$}} +\begingroup \catcode`\_=8 +\gdef\NAT@ifcat@num#1{% + \ifcat_\ifnum\z@<0#1_\else A\fi + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +}% +\endgroup \providecommand\@firstofone[1]{#1} \newcommand\NAT@citexnum{} \def\NAT@citexnum[#1][#2]#3{% - \NAT@sort@cites{#3}% - \let\@citea\@empty + \NAT@reset@parser + \NAT@sort@cites{#3}% + \NAT@reset@citea \@cite{\def\NAT@num{-1}\let\NAT@last@yr\relax\let\NAT@nm\@empty - \ifNAT@swa\else - \ifnum\NAT@ctype=0\if*#1*\else - #1\ \fi\fi\fi \@for\@citeb:=\NAT@cite@list\do - {\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% - \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}% - \@ifundefined{@cprwrite}{}{\expandafter\@cprwrite\@citeb=}\fi + {\@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \@ifundefined{b@\@citeb\@extra@b@citeb}{% {\reset@font\bfseries?} \NAT@citeundefined\PackageWarning{natbib}% @@ -357,95 +394,132 @@ \ifNAT@full\let\NAT@nm\NAT@all@names\else \let\NAT@nm\NAT@name\fi \ifNAT@swa - \ifnum\NAT@ctype>1\relax\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \ifnum\NAT@ctype=2\relax\NAT@test{\NAT@ctype}% - \else\NAT@alias - \fi\hyper@natlinkend\else - \ifnum\NAT@cmprs>0 - \begingroup\catcode`\_=8 - \ifcat _\ifnum\z@<0\NAT@num _\else A\fi - \global\let\NAT@nm=\NAT@num \else \gdef\NAT@nm{-2}\fi - \ifcat _\ifnum\z@<0\NAT@last@num _\else A\fi - \global\@tempcnta=\NAT@last@num \global\advance\@tempcnta by\@ne - \else \global\@tempcnta\m@ne\fi - \endgroup - \ifnum\NAT@nm=\@tempcnta - \ifx\NAT@last@yr\relax - \protected@edef\NAT@last@yr{\@citea \mbox{% - \noexpand\hyper@natlinkstart{\@citeb\@extra@b@citeb}{% - \noexpand\citenumfont{\NAT@num}}\noexpand\hyper@natlinkend}}% - \else - \protected@edef\NAT@last@yr{--\penalty\@m\mbox{% - \noexpand\hyper@natlinkstart{\@citeb\@extra@b@citeb}{% - \noexpand\citenumfont{\NAT@num}}\noexpand\hyper@natlinkend}}% - \fi - \else - \NAT@last@yr \@citea \mbox{\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - {\citenumfont{\NAT@num}}\hyper@natlinkend}% - \let\NAT@last@yr\relax - \fi - \else - \@citea \mbox{\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - {\citenumfont{\NAT@num}}\hyper@natlinkend}% - \fi - \fi - \def\@citea{\NAT@sep\penalty\@m\NAT@space}% + \@ifnum{\NAT@ctype>\@ne}{% + \@citea + \NAT@hyper@{\@ifnum{\NAT@ctype=\tw@}{\NAT@test{\NAT@ctype}}{\NAT@alias}}% + }{% + \@ifnum{\NAT@cmprs>\z@}{% + \NAT@ifcat@num\NAT@num + {\let\NAT@nm=\NAT@num}% + {\def\NAT@nm{-2}}% + \NAT@ifcat@num\NAT@last@num + {\@tempcnta=\NAT@last@num\relax}% + {\@tempcnta\m@ne}% + \@ifnum{\NAT@nm=\@tempcnta}{% + \@ifnum{\NAT@merge>\@ne}{}{\NAT@last@yr@mbox}% + }{% + \advance\@tempcnta by\@ne + \@ifnum{\NAT@nm=\@tempcnta}{% + \ifx\NAT@last@yr\relax + \def@NAT@last@yr{\@citea}% + \else + \def@NAT@last@yr{--\NAT@penalty}% + \fi + }{% + \NAT@last@yr@mbox + }% + }% + }{% + \@tempswatrue + \@ifnum{\NAT@merge>\@ne}{\@ifnum{\NAT@last@num=\NAT@num\relax}{\@tempswafalse}{}}{}% + \if@tempswa\NAT@citea@mbox\fi + }% + }% + \NAT@def@citea \else - \ifcase\NAT@ctype\relax - \ifx\NAT@last@nm\NAT@nm \NAT@yrsep\penalty\@m\NAT@space\else - \@citea \NAT@test{1}\ \NAT@mbox{\NAT@@open}% - \fi \NAT@mbox{% - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - {\citenumfont{\NAT@num}}\hyper@natlinkend}% - \def\@citea{\NAT@mbox{\NAT@@close\NAT@sep\penalty\@m\ }}% - \or\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@test{\NAT@ctype}\hyper@natlinkend - \def\@citea{\NAT@sep\penalty\@m\ }% - \or\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@test{\NAT@ctype}\hyper@natlinkend - \def\@citea{\NAT@sep\penalty\@m\ }% - \or\@citea - \hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \def\@citea{\NAT@sep\penalty\@m\ }% + \ifcase\NAT@ctype + \ifx\NAT@last@nm\NAT@nm \NAT@yrsep\NAT@penalty\NAT@space\else + \@citea \NAT@test{\@ne}\NAT@spacechar\NAT@mbox{\NAT@super@kern\NAT@@open}% + \fi + \if*#1*\else#1\NAT@spacechar\fi + \NAT@mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}% + \NAT@def@citea@box + \or + \NAT@hyper@citea@space{\NAT@test{\NAT@ctype}}% + \or + \NAT@hyper@citea@space{\NAT@test{\NAT@ctype}}% + \or + \NAT@hyper@citea@space\NAT@alias \fi \fi - }}% - \ifnum\NAT@cmprs>0\relax\NAT@last@yr\fi - \ifNAT@swa\else\NAT@mbox{\NAT@@close}% - \ifnum\NAT@ctype=0\if*#2*\else - \NAT@cmt#2\fi - \fi\fi}{#1}{#2}} -\newcommand\NAT@test[1]{\ifnum#1=1 \ifx\NAT@nmfmt{\NAT@nm}\NAT@noname - {\reset@font\bfseries(author?)}\PackageWarning{natbib} - {Author undefined for citation`\@citeb' - \MessageBreak - on page \thepage}\else \NAT@nm \fi - \else \if\relax\NAT@date\relax - {\reset@font\bfseries(year?)}\PackageWarning{natbib} - {Year undefined for citation`\@citeb' - \MessageBreak - on page \thepage}\else \NAT@date \fi \fi} -\let\citenumfont=\relax + }% + }% + \@ifnum{\NAT@cmprs>\z@}{\NAT@last@yr}{}% + \ifNAT@swa\else + \@ifnum{\NAT@ctype=\z@}{% + \if*#2*\else\NAT@cmt#2\fi + }{}% + \NAT@mbox{\NAT@@close}% + \fi + }{#1}{#2}% +}% +\def\NAT@citea@mbox{% + \@citea\mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}% +}% +\def\NAT@hyper@#1{% + \hyper@natlinkstart{\@citeb\@extra@b@citeb}#1\hyper@natlinkend +}% +\def\NAT@hyper@citea#1{% + \@citea + \NAT@hyper@{#1}% + \NAT@def@citea +}% +\def\NAT@hyper@citea@space#1{% + \@citea + \NAT@hyper@{#1}% + \NAT@def@citea@space +}% +\def\def@NAT@last@yr#1{% + \protected@edef\NAT@last@yr{% + #1% + \noexpand\mbox{% + \noexpand\hyper@natlinkstart{\@citeb\@extra@b@citeb}% + {\noexpand\citenumfont{\NAT@num}}% + \noexpand\hyper@natlinkend + }% + }% +}% +\def\NAT@last@yr@mbox{% + \NAT@last@yr\let\NAT@last@yr\relax + \NAT@citea@mbox +}% +\newcommand\NAT@test[1]{% + \@ifnum{#1=\@ne}{% + \ifx\NAT@nm\NAT@noname + \begingroup\reset@font\bfseries(author?)\endgroup + \PackageWarning{natbib}{% + Author undefined for citation`\@citeb' \MessageBreak on page \thepage% + }% + \else \NAT@nm + \fi + }{% + \if\relax\NAT@date\relax + \begingroup\reset@font\bfseries(year?)\endgroup + \PackageWarning{natbib}{% + Year undefined for citation`\@citeb' \MessageBreak on page \thepage% + }% + \else \NAT@date + \fi + }% +}% +\let\citenumfont=\@empty \newcommand\NAT@citex{} \def\NAT@citex% [#1][#2]#3{% + \NAT@reset@parser \NAT@sort@cites{#3}% - \let\@citea\@empty + \NAT@reset@citea \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty \@for\@citeb:=\NAT@cite@list\do - {\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% - \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}% - \@ifundefined{@cprwrite}{}{\expandafter\@cprwrite\@citeb=}\fi + {\@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea% {\reset@font\bfseries ?}\NAT@citeundefined \PackageWarning{natbib}% {Citation `\@citeb' on page \thepage \space undefined}\def\NAT@date{}}% {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year - \NAT@parse{\@citeb}% + \NAT@parse{\@citeb}% \ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{% \let\NAT@name=\NAT@all@names \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}% @@ -454,8 +528,7 @@ \let\NAT@nm\NAT@name\fi \ifNAT@swa\ifcase\NAT@ctype \if\relax\NAT@date\relax - \@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\NAT@date\hyper@natlinkend + \@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}\NAT@date}% \else \ifx\NAT@last@nm\NAT@nm\NAT@yrsep \ifx\NAT@last@yr\NAT@year @@ -464,29 +537,28 @@ {Multiple citation on page \thepage: same authors and year\MessageBreak without distinguishing extra letter,\MessageBreak appears as question mark}\fi - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab - \hyper@natlinkend - \else\unskip\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date - \hyper@natlinkend + \NAT@hyper@{\NAT@exlab}% + \else\unskip\NAT@spacechar + \NAT@hyper@{\NAT@date}% \fi - \else\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}% - \hyper@natlinkbreak{\NAT@aysep\ }{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend + \else + \@citea\NAT@hyper@{% + \NAT@nmfmt{\NAT@nm}% + \hyper@natlinkbreak{% + \NAT@aysep\NAT@spacechar}{\@citeb\@extra@b@citeb + }% + \NAT@date + }% \fi \fi - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \fi \def\@citea{\NAT@sep\ }% - \else\ifcase\NAT@ctype + \or\@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}% + \or\@citea\NAT@hyper@{\NAT@date}% + \or\@citea\NAT@hyper@{\NAT@alias}% + \fi \NAT@def@citea + \else + \ifcase\NAT@ctype \if\relax\NAT@date\relax - \@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend + \@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}% \else \ifx\NAT@last@nm\NAT@nm\NAT@yrsep \ifx\NAT@last@yr\NAT@year @@ -495,29 +567,39 @@ {Multiple citation on page \thepage: same authors and year\MessageBreak without distinguishing extra letter,\MessageBreak appears as question mark}\fi - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@exlab - \hyper@natlinkend - \else\unskip\ - \hyper@natlinkstart{\@citeb\@extra@b@citeb}\NAT@date - \hyper@natlinkend + \NAT@hyper@{\NAT@exlab}% + \else + \unskip\NAT@spacechar + \NAT@hyper@{\NAT@date}% \fi - \else\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}% - \hyper@natlinkbreak{\ \NAT@@open\if*#1*\else#1\ \fi}% - {\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend\fi + \else + \@citea\NAT@hyper@{% + \NAT@nmfmt{\NAT@nm}% + \hyper@natlinkbreak{\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi}% + {\@citeb\@extra@b@citeb}% + \NAT@date + }% + \fi \fi - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@nmfmt{\NAT@nm}\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@date\hyper@natlinkend - \or\@citea\hyper@natlinkstart{\@citeb\@extra@b@citeb}% - \NAT@alias\hyper@natlinkend - \fi \if\relax\NAT@date\relax\def\@citea{\NAT@sep\ }% - \else\def\@citea{\NAT@@close\NAT@sep\ }\fi + \or\@citea\NAT@hyper@{\NAT@nmfmt{\NAT@nm}}% + \or\@citea\NAT@hyper@{\NAT@date}% + \or\@citea\NAT@hyper@{\NAT@alias}% + \fi + \if\relax\NAT@date\relax + \NAT@def@citea + \else + \NAT@def@citea@close + \fi \fi }}\ifNAT@swa\else\if*#2*\else\NAT@cmt#2\fi \if\relax\NAT@date\relax\else\NAT@@close\fi\fi}{#1}{#2}} +\def\NAT@spacechar{\ }% +\def\NAT@separator{\NAT@sep\NAT@penalty}% +\def\NAT@reset@citea{\c@NAT@ctr\@ne\let\@citea\@empty}% +\def\NAT@def@citea{\def\@citea{\NAT@separator\NAT@space}}% +\def\NAT@def@citea@space{\def\@citea{\NAT@separator\NAT@spacechar}}% +\def\NAT@def@citea@close{\def\@citea{\NAT@@close\NAT@separator\NAT@space}}% +\def\NAT@def@citea@box{\def\@citea{\NAT@mbox{\NAT@@close}\NAT@separator\NAT@spacechar}}% \newif\ifNAT@par \NAT@partrue \newcommand\NAT@@open{\ifNAT@par\NAT@open\fi} \newcommand\NAT@@close{\ifNAT@par\NAT@close\fi} @@ -533,7 +615,9 @@ \let\@tempa\relax\else#1\fi\@tempa} \newcommand\shortcites[1]{% \@bsphack\@for\@citeb:=#1\do - {\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + {\@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \global\@namedef{bv@\@citeb\@extra@b@citeb}{}}\@esphack} \newcommand\NAT@biblabel[1]{\hfill} \newcommand\NAT@biblabelnum[1]{\bibnumfmt{#1}} @@ -558,27 +642,35 @@ \newcommand\NAT@bibsetup% [1]{\setlength{\leftmargin}{\bibhang}\setlength{\itemindent}{-\leftmargin}% \setlength{\itemsep}{\bibsep}\setlength{\parsep}{\z@}} -\newcommand\NAT@set@cites{\ifNAT@numbers - \ifNAT@super \let\@cite\NAT@citesuper - \def\NAT@mbox##1{\unskip\nobreak\hspace{1\p@}\textsuperscript{##1}}% - \let\citeyearpar=\citeyear - \let\NAT@space\relax\else - \let\NAT@mbox=\mbox - \let\@cite\NAT@citenum \def\NAT@space{ }\fi - \let\@citex\NAT@citexnum - \let\@biblabel\NAT@biblabelnum - \let\@bibsetup\NAT@bibsetnum - \renewcommand\NAT@idxtxt{\NAT@name\ \NAT@open\NAT@num\NAT@close}% - \def\natexlab##1{}% - \else - \let\@cite\NAT@cite - \let\@citex\NAT@citex - \let\@biblabel\NAT@biblabel - \let\@bibsetup\NAT@bibsetup - \let\NAT@space\relax - \renewcommand\NAT@idxtxt{\NAT@name\ \NAT@open\NAT@date\NAT@close}% - \def\natexlab##1{##1}% - \fi} +\newcommand\NAT@set@cites{% + \ifNAT@numbers + \ifNAT@super \let\@cite\NAT@citesuper + \def\NAT@mbox##1{\unskip\nobreak\textsuperscript{##1}}% + \let\citeyearpar=\citeyear + \let\NAT@space\relax + \def\NAT@super@kern{\kern\p@}% + \else + \let\NAT@mbox=\mbox + \let\@cite\NAT@citenum + \let\NAT@space\NAT@spacechar + \let\NAT@super@kern\relax + \fi + \let\@citex\NAT@citexnum + \let\@biblabel\NAT@biblabelnum + \let\@bibsetup\NAT@bibsetnum + \renewcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@num\NAT@close}% + \def\natexlab##1{}% + \def\NAT@penalty{\penalty\@m}% + \else + \let\@cite\NAT@cite + \let\@citex\NAT@citex + \let\@biblabel\NAT@biblabel + \let\@bibsetup\NAT@bibsetup + \let\NAT@space\NAT@spacechar + \let\NAT@penalty\@empty + \renewcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@date\NAT@close}% + \def\natexlab##1{##1}% + \fi} \AtBeginDocument{\NAT@set@cites} \AtBeginDocument{\ifx\SK@def\@undefined\else \ifx\SK@cite\@empty\else @@ -591,16 +683,16 @@ \newif\ifNAT@full\NAT@fullfalse \newif\ifNAT@swa \DeclareRobustCommand\citet - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \newcommand\NAT@citetp{\@ifnextchar[{\NAT@@citetp}{\NAT@@citetp[]}} \newcommand\NAT@@citetp{} \def\NAT@@citetp[#1]{\@ifnextchar[{\@citex[#1]}{\@citex[][#1]}} \DeclareRobustCommand\citep - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@partrue \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\cite - {\begingroup\def\NAT@ctype{0}\NAT@partrue\NAT@swatrue + {\begingroup\let\NAT@ctype\z@\NAT@partrue\NAT@swatrue \@ifstar{\NAT@fulltrue\NAT@cites}{\NAT@fullfalse\NAT@cites}} \newcommand\NAT@cites{\@ifnextchar [{\NAT@@citetp}{% \ifNAT@numbers\else @@ -608,41 +700,42 @@ \fi \NAT@@citetp[]}} \DeclareRobustCommand\citealt - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@parfalse \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\citealp - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@parfalse \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\citenum - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@parfalse\let\textsuperscript\ - \NAT@citexnum[][]} + {\begingroup + \NAT@swatrue\let\NAT@ctype\z@\NAT@parfalse\let\textsuperscript\NAT@spacechar + \NAT@citexnum[][]} \DeclareRobustCommand\citeauthor - {\begingroup\NAT@swafalse\def\NAT@ctype{1}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\@ne\NAT@parfalse \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citet - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@partrue \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citep - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@partrue + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@partrue \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citealt - {\begingroup\NAT@swafalse\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\z@\NAT@parfalse \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citealp - {\begingroup\NAT@swatrue\def\NAT@ctype{0}\NAT@parfalse + {\begingroup\NAT@swatrue\let\NAT@ctype\z@\NAT@parfalse \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\Citeauthor - {\begingroup\NAT@swafalse\def\NAT@ctype{1}\NAT@parfalse + {\begingroup\NAT@swafalse\let\NAT@ctype\@ne\NAT@parfalse \let\NAT@up\NAT@Up \@ifstar{\NAT@fulltrue\NAT@citetp}{\NAT@fullfalse\NAT@citetp}} \DeclareRobustCommand\citeyear - {\begingroup\NAT@swafalse\def\NAT@ctype{2}\NAT@parfalse\NAT@citetp} + {\begingroup\NAT@swafalse\let\NAT@ctype\tw@\NAT@parfalse\NAT@citetp} \DeclareRobustCommand\citeyearpar - {\begingroup\NAT@swatrue\def\NAT@ctype{2}\NAT@partrue\NAT@citetp} + {\begingroup\NAT@swatrue\let\NAT@ctype\tw@\NAT@partrue\NAT@citetp} \newcommand\citetext[1]{\NAT@open#1\NAT@close} \DeclareRobustCommand\citefullauthor {\citeauthor*} @@ -651,30 +744,45 @@ {\PackageWarning{natbib}{Overwriting existing alias for citation #1}} \@namedef{al@#1\@extra@b@citeb}{#2}} \DeclareRobustCommand\citetalias{\begingroup - \NAT@swafalse\def\NAT@ctype{3}\NAT@parfalse\NAT@citetp} + \NAT@swafalse\let\NAT@ctype\thr@@\NAT@parfalse\NAT@citetp} \DeclareRobustCommand\citepalias{\begingroup - \NAT@swatrue\def\NAT@ctype{3}\NAT@partrue\NAT@citetp} + \NAT@swatrue\let\NAT@ctype\thr@@\NAT@partrue\NAT@citetp} \renewcommand\nocite[1]{\@bsphack \@for\@citeb:=#1\do{% + \@safe@activestrue \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi \if*\@citeb\else \@ifundefined{b@\@citeb\@extra@b@citeb}{% \NAT@citeundefined \PackageWarning{natbib}% {Citation `\@citeb' undefined}}{}\fi}% \@esphack} -\newcommand\NAT@parse[1]{{% - \let\protect=\@unexpandable@protect\let~\relax - \let\active@prefix=\@gobble - \xdef\NAT@temp{\csname b@#1\@extra@b@citeb\endcsname}}% - \expandafter\NAT@split\NAT@temp - \expandafter\NAT@parse@date\NAT@date??????@@% - \ifciteindex\NAT@index\fi -} -\newcommand\NAT@split[4]{% +\newcommand\NAT@parse[1]{% + \begingroup + \let\protect=\@unexpandable@protect + \let~\relax + \let\active@prefix=\@gobble + \edef\NAT@temp{\csname b@#1\@extra@b@citeb\endcsname}% + \aftergroup\NAT@split + \expandafter + \endgroup + \NAT@temp{}{}{}{}{}@@% + \expandafter\NAT@parse@date\NAT@date??????@@% + \ifciteindex\NAT@index\fi +}% +\def\NAT@split#1#2#3#4#5@@{% \gdef\NAT@num{#1}\gdef\NAT@name{#3}\gdef\NAT@date{#2}% \gdef\NAT@all@names{#4}% - \ifx\NAT@noname\NAT@all@names \gdef\NAT@all@names{#3}\fi} + \ifx\NAT@num\@empty\gdef\NAT@num{0}\fi + \ifx\NAT@noname\NAT@all@names \gdef\NAT@all@names{#3}\fi +}% +\def\NAT@reset@parser{% + \global\let\NAT@num\@empty + \global\let\NAT@name\@empty + \global\let\NAT@date\@empty + \global\let\NAT@all@names\@empty +}% \newcommand\NAT@parse@date{} \def\NAT@parse@date#1#2#3#4#5#6@@{% \ifnum\the\catcode`#1=11\def\NAT@year{}\def\NAT@exlab{#1}\else @@ -687,14 +795,14 @@ \renewcommand\makeindex{\NAT@makeindex \renewcommand\NAT@index{\@bsphack\begingroup \def~{\string~}\@wrindex{\NAT@idxtxt}}} -\newcommand\NAT@idxtxt{\NAT@name\ \NAT@open\NAT@date\NAT@close} -\@ifundefined{@indexfile}{}{\let\NAT@makeindex\relax\makeindex} +\newcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@date\NAT@close} +\@ifxundefined\@indexfile{}{\let\NAT@makeindex\relax\makeindex} \newif\ifciteindex \citeindexfalse \newcommand\citeindextype{default} \newcommand\NAT@index@alt{{\let\protect=\noexpand\let~\relax \xdef\NAT@temp{\NAT@idxtxt}}\expandafter\NAT@exp\NAT@temp\@nil} \newcommand\NAT@exp{} -\def\NAT@exp#1\@nil{\mbox{}\index[\citeindextype]{#1}} +\def\NAT@exp#1\@nil{\index[\citeindextype]{#1}} \AtBeginDocument{% \@ifpackageloaded{index}{\let\NAT@index=\NAT@index@alt}{}} @@ -702,9 +810,9 @@ \newcommand\NAT@ifxcmd{\ifx\NAT@temp\relax\else\expandafter\NAT@bare\fi} \def\NAT@bare#1(#2)#3(@)#4\@nil#5{% \if @#2 - \expandafter\NAT@apalk#1, , \@nil{#5}\else - \stepcounter{NAT@ctr}% - \NAT@wrout{\arabic {NAT@ctr}}{#2}{#1}{#3}{#5} + \expandafter\NAT@apalk#1, , \@nil{#5}% + \else + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{#3}{#5}% \fi } \newcommand\NAT@wrout[5]{% @@ -714,61 +822,208 @@ \write\@auxout{\string\bibcite{#5}{{#1}{#2}{{#3}}{{#4}}}}}\fi \ignorespaces} \def\NAT@noname{{}} -\renewcommand\bibitem{% - \@ifnextchar[{\@lbibitem}{% - \global\NAT@stdbsttrue - \stepcounter{NAT@ctr}\@lbibitem[\arabic{NAT@ctr}]}} +\renewcommand\bibitem{\@ifnextchar[{\@lbibitem}{\@lbibitem[]}}% +\let\NAT@bibitem@first@sw\@secondoftwo \def\@lbibitem[#1]#2{% \if\relax\@extra@b@citeb\relax\else \@ifundefined{br@#2\@extra@b@citeb}{}{% - \@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi - \@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}% - \item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}\@biblabel{\NAT@num}% - \hyper@natanchorend]% - \NAT@ifcmd#1(@)(@)\@nil{#2}} + \@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}% + }% + \fi + \@ifundefined{b@#2\@extra@b@citeb}{% + \def\NAT@num{}% + }{% + \NAT@parse{#2}% + }% + \def\NAT@tmp{#1}% + \expandafter\let\expandafter\bibitemOpen\csname NAT@b@open@#2\endcsname + \expandafter\let\expandafter\bibitemShut\csname NAT@b@shut@#2\endcsname + \@ifnum{\NAT@merge>\@ne}{% + \NAT@bibitem@first@sw{% + \@firstoftwo + }{% + \@ifundefined{NAT@b*@#2}{% + \@firstoftwo + }{% + \expandafter\def\expandafter\NAT@num\expandafter{\the\c@NAT@ctr}% + \@secondoftwo + }% + }% + }{% + \@firstoftwo + }% + {% + \global\advance\c@NAT@ctr\@ne + \@ifx{\NAT@tmp\@empty}{\@firstoftwo}{% + \@secondoftwo + }% + {% + \expandafter\def\expandafter\NAT@num\expandafter{\the\c@NAT@ctr}% + \global\NAT@stdbsttrue + }{}% + \bibitem@fin + \item[\hfil\NAT@anchor{#2}{\NAT@num}]% + \global\let\NAT@bibitem@first@sw\@secondoftwo + \NAT@bibitem@init + }% + {% + \NAT@anchor{#2}{}% + \NAT@bibitem@cont + \bibitem@fin + }% + \@ifx{\NAT@tmp\@empty}{% + \NAT@wrout{\the\c@NAT@ctr}{}{}{}{#2}% + }{% + \expandafter\NAT@ifcmd\NAT@tmp(@)(@)\@nil{#2}% + }% +}% +\def\bibitem@fin{% + \@ifxundefined\@bibstop{}{\csname bibitem@\@bibstop\endcsname}% +}% +\def\NAT@bibitem@init{% + \let\@bibstop\@undefined +}% +\def\NAT@bibitem@cont{% + \let\bibitem@Stop\bibitemStop + \let\bibitem@NoStop\bibitemContinue +}% +\def\BibitemOpen{% + \bibitemOpen +}% +\def\BibitemShut#1{% + \bibitemShut + \def\@bibstop{#1}% + \let\bibitem@Stop\bibitemStop + \let\bibitem@NoStop\bibitemNoStop +}% +\def\bibitemStop{}% +\def\bibitemNoStop{.\spacefactor\@mmm\space}% +\def\bibitemContinue{\spacefactor\@mmm\space}% +\mathchardef\@mmm=3000 % +\providecommand{\bibAnnote}[3]{% + \BibitemShut{#1}% + \def\@tempa{#3}\@ifx{\@tempa\@empty}{}{% + \begin{quotation}\noindent + \textsc{Key:}\ #2\\\textsc{Annotation:}\ \@tempa + \end{quotation}% + }% +}% +\providecommand{\bibAnnoteFile}[2]{% + \IfFileExists{#2}{% + \bibAnnote{#1}{#2}{\input{#2}}% + }{% + \bibAnnote{#1}{#2}{}% + }% +}% +\let\bibitemOpen\relax +\let\bibitemShut\relax +\def\bibfield{\@ifnum{\NAT@merge>\tw@}{\@bibfield}{\@secondoftwo}}% +\def\@bibfield#1#2{% + \begingroup + \let\Doi\@gobble + \let\bibinfo\relax + \let\restore@protect\@empty + \protected@edef\@tempa{#2}% + \aftergroup\def\aftergroup\@tempa + \expandafter\endgroup\expandafter{\@tempa}% + \expandafter\@ifx\expandafter{\csname @bib#1\endcsname\@tempa}{% + \expandafter\let\expandafter\@tempa\csname @bib@X#1\endcsname + }{% + \expandafter\let\csname @bib#1\endcsname\@tempa + \expandafter\let\expandafter\@tempa\csname @bib@Y#1\endcsname + }% + \@ifx{\@tempa\relax}{\let\@tempa\@firstofone}{}% + \@tempa{#2}% +}% +\def\bibinfo#1{% + \expandafter\let\expandafter\@tempa\csname bibinfo@X@#1\endcsname + \@ifx{\@tempa\relax}{\@firstofone}{\@tempa}% +}% +\def\@bib@Xauthor#1{\let\@bib@Xjournal\@gobble}% +\def\@bib@Xjournal#1{\begingroup\let\bibinfo@X@journal\@bib@Z@journal#1\endgroup}% +\def\@bibibid@#1{\textit{ibid}.}% +\appdef\NAT@bibitem@init{% + \let\@bibauthor \@empty + \let\@bibjournal \@empty + \let\@bib@Z@journal\@bibibid@ +}% \ifx\SK@lbibitem\@undefined\else \let\SK@lbibitem\@lbibitem \def\@lbibitem[#1]#2{% \SK@lbibitem[#1]{#2}\SK@\SK@@label{#2}\ignorespaces}\fi \newif\ifNAT@stdbst \NAT@stdbstfalse -\AtEndDocument - {\ifNAT@stdbst\if@filesw\immediate\write\@auxout{\string - \global\string\NAT@numberstrue}\fi\fi - } +\AtEndDocument{% + \ifNAT@stdbst\if@filesw + \immediate\write\@auxout{% + \string\providecommand\string\NAT@force@numbers{}% + \string\NAT@force@numbers + }% + \fi\fi + } +\newcommand\NAT@force@numbers{% + \ifNAT@numbers\else + \PackageError{natbib}{Bibliography not compatible with author-year + citations.\MessageBreak + Press <return> to continue in numerical citation style} + {Check the bibliography entries for non-compliant syntax,\MessageBreak + or select author-year BibTeX style, e.g. plainnat}% + \global\NAT@numberstrue\fi} + \providecommand\bibcite{} -\renewcommand\bibcite[2]{\@ifundefined{b@#1\@extra@binfo}\relax - {\NAT@citemultiple - \PackageWarningNoLine{natbib}{Citation `#1' multiply defined}}% - \global\@namedef{b@#1\@extra@binfo}{#2}} +\renewcommand\bibcite[2]{% + \@ifundefined{b@#1\@extra@binfo}{\relax}{% + \NAT@citemultiple + \PackageWarningNoLine{natbib}{Citation `#1' multiply defined}% + }% + \global\@namedef{b@#1\@extra@binfo}{#2}% +}% \AtEndDocument{\NAT@swatrue\let\bibcite\NAT@testdef} \newcommand\NAT@testdef[2]{% - \def\NAT@temp{#2}\expandafter \ifx \csname b@#1\@extra@binfo\endcsname - \NAT@temp \else \ifNAT@swa \NAT@swafalse - \PackageWarningNoLine{natbib}{Citation(s) may have - changed.\MessageBreak - Rerun to get citations correct}\fi\fi} + \def\NAT@temp{#2}% + \expandafter \ifx \csname b@#1\@extra@binfo\endcsname\NAT@temp + \else + \ifNAT@swa \NAT@swafalse + \PackageWarningNoLine{natbib}{% + Citation(s) may have changed.\MessageBreak + Rerun to get citations correct% + }% + \fi + \fi +}% \newcommand\NAT@apalk{} -\def\NAT@apalk#1, #2, #3\@nil#4{\if\relax#2\relax - \global\NAT@stdbsttrue - \NAT@wrout{#1}{}{}{}{#4}\else - \stepcounter{NAT@ctr}% - \NAT@wrout{\arabic {NAT@ctr}}{#2}{#1}{}{#4}\fi} +\def\NAT@apalk#1, #2, #3\@nil#4{% + \if\relax#2\relax + \global\NAT@stdbsttrue + \NAT@wrout{#1}{}{}{}{#4}% + \else + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{}{#4}% + \fi +}% \newcommand\citeauthoryear{} -\def\citeauthoryear#1#2#3(@)(@)\@nil#4{\stepcounter{NAT@ctr}\if\relax#3\relax - \NAT@wrout{\arabic {NAT@ctr}}{#2}{#1}{}{#4}\else - \NAT@wrout{\arabic {NAT@ctr}}{#3}{#2}{#1}{#4}\fi} -\newcommand\citestarts{\NAT@open} -\newcommand\citeends{\NAT@close} -\newcommand\betweenauthors{and} +\def\citeauthoryear#1#2#3(@)(@)\@nil#4{% + \if\relax#3\relax + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{}{#4}% + \else + \NAT@wrout{\the\c@NAT@ctr}{#3}{#2}{#1}{#4}% + \fi +}% +\newcommand\citestarts{\NAT@open}% +\newcommand\citeends{\NAT@close}% +\newcommand\betweenauthors{and}% \newcommand\astroncite{} -\def\astroncite#1#2(@)(@)\@nil#3{\stepcounter{NAT@ctr}\NAT@wrout{\arabic -{NAT@ctr}}{#2}{#1}{}{#3}} +\def\astroncite#1#2(@)(@)\@nil#3{% + \NAT@wrout{\the\c@NAT@ctr}{#2}{#1}{}{#3}% +}% \newcommand\citename{} \def\citename#1#2(@)(@)\@nil#3{\expandafter\NAT@apalk#1#2, \@nil{#3}} -\newcommand\harvarditem[4][]% - {\if\relax#1\relax\bibitem[#2(#3)]{#4}\else - \bibitem[#1(#3)#2]{#4}\fi } +\newcommand\harvarditem[4][]{% + \if\relax#1\relax + \bibitem[#2(#3)]{#4}% + \else + \bibitem[#1(#3)#2]{#4}% + \fi +}% \newcommand\harvardleft{\NAT@open} \newcommand\harvardright{\NAT@close} \newcommand\harvardyearleft{\NAT@open} @@ -776,39 +1031,54 @@ \AtBeginDocument{\providecommand{\harvardand}{and}} \newcommand\harvardurl[1]{\textbf{URL:} \textit{#1}} \providecommand\bibsection{} -\@ifundefined{chapter}% - {\renewcommand\bibsection{\section*{\refname - \@mkboth{\MakeUppercase{\refname}}{\MakeUppercase{\refname}}}}} - {\@ifundefined{NAT@sectionbib}% - {\renewcommand\bibsection{\chapter*{\bibname - \@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}}} - {\renewcommand\bibsection{\section*{\bibname - \ifx\@mkboth\@gobbletwo\else\markright{\MakeUppercase{\bibname}}\fi}}}} -\@ifclassloaded{amsart}% - {\renewcommand\bibsection{\section*{\refname}}}{} -\@ifclassloaded{amsbook}% - {\renewcommand\bibsection{\chapter*{\bibname}}}{} -\@ifundefined{bib@heading}{}{\let\bibsection\bib@heading} +\@ifundefined{chapter}{% + \renewcommand\bibsection{% + \section*{\refname\@mkboth{\MakeUppercase{\refname}}{\MakeUppercase{\refname}}}% + }% +}{% + \@ifxundefined\NAT@sectionbib{% + \renewcommand\bibsection{% + \chapter*{\bibname\@mkboth{\MakeUppercase{\bibname}}{\MakeUppercase{\bibname}}}% + }% + }{% + \renewcommand\bibsection{% + \section*{\bibname\ifx\@mkboth\@gobbletwo\else\markright{\MakeUppercase{\bibname}}\fi}% + }% + }% +}% +\@ifclassloaded{amsart}{\renewcommand\bibsection{\section*{\refname}}}{}% +\@ifclassloaded{amsbook}{\renewcommand\bibsection{\chapter*{\bibname}}}{}% +\@ifxundefined\bib@heading{}{\let\bibsection\bib@heading}% \newcounter{NAT@ctr} \renewenvironment{thebibliography}[1]{% - \bibsection\parindent \z@\bibpreamble\bibfont\list - {\@biblabel{\arabic{NAT@ctr}}}{\@bibsetup{#1}% - \setcounter{NAT@ctr}{0}}% - \ifNAT@openbib - \renewcommand\newblock{\par} - \else - \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}% - \fi - \sloppy\clubpenalty4000\widowpenalty4000 - \sfcode`\.=1000\relax + \bibsection + \parindent\z@ + \bibpreamble + \bibfont + \list{\@biblabel{\the\c@NAT@ctr}}{\@bibsetup{#1}\global\c@NAT@ctr\z@}% + \ifNAT@openbib + \renewcommand\newblock{\par}% + \else + \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}% + \fi + \sloppy\clubpenalty4000\widowpenalty4000 + \sfcode`\.\@m + \let\NAT@bibitem@first@sw\@firstoftwo \let\citeN\cite \let\shortcite\cite \let\citeasnoun\cite - }{\def\@noitemerr{% - \PackageWarning{natbib} - {Empty `thebibliography' environment}}% - \endlist\vskip-\lastskip} - \let\bibfont\relax -\let\bibpreamble\relax +}{% + \bibitem@fin + \bibpostamble + \def\@noitemerr{% + \PackageWarning{natbib}{Empty `thebibliography' environment}% + }% + \endlist + \bibcleanup +}% +\let\bibfont\@empty +\let\bibpreamble\@empty +\let\bibpostamble\@empty +\def\bibcleanup{\vskip-\lastskip}% \providecommand\reset@font{\relax} \providecommand\bibname{Bibliography} \providecommand\refname{References} @@ -823,74 +1093,146 @@ \providecommand\MakeUppercase{\uppercase} \providecommand{\@extra@b@citeb}{} \gdef\@extra@binfo{} -\providecommand\hyper@natanchorstart[1]{} -\providecommand\hyper@natanchorend{} -\providecommand\hyper@natlinkstart[1]{} -\providecommand\hyper@natlinkend{} -\providecommand\hyper@natlinkbreak[2]{#1} -\@ifundefined{bbl@redefine}{}{% - \bbl@redefine\nocite#1{% - \@safe@activestrue\org@nocite{#1}\@safe@activesfalse}% -\bbl@redefine\@lbibitem[#1]#2{% - \@safe@activestrue\org@@lbibitem[#1]{#2}\@safe@activesfalse}% -} -\AtBeginDocument{\@ifundefined{bbl@redefine}{}{% -\bbl@redefine\@citex[#1][#2]#3{% - \@safe@activestrue\org@@citex[#1][#2]{#3}\@safe@activesfalse}% -\bbl@redefine\NAT@testdef#1#2{% - \@safe@activestrue\org@NAT@testdef{#1}{#2}\@safe@activesfalse}% -\@ifundefined{org@@lbibitem}{% -\bbl@redefine\@lbibitem[#1]#2{% - \@safe@activestrue\org@@lbibitem[#1]{#2}\@safe@activesfalse}}{}% -}} -\ifnum\NAT@sort>0 +\def\NAT@anchor#1#2{% + \hyper@natanchorstart{#1\@extra@b@citeb}% + \def\@tempa{#2}\@ifx{\@tempa\@empty}{}{\@biblabel{#2}}% + \hyper@natanchorend +}% +\providecommand\hyper@natanchorstart[1]{}% +\providecommand\hyper@natanchorend{}% +\providecommand\hyper@natlinkstart[1]{}% +\providecommand\hyper@natlinkend{}% +\providecommand\hyper@natlinkbreak[2]{#1}% +\AtBeginDocument{% + \@ifpackageloaded{babel}{% + \let\org@@citex\@citex}{}} +\providecommand\@safe@activestrue{}% +\providecommand\@safe@activesfalse{}% + \newcommand\NAT@sort@cites[1]{% -\@tempcntb\m@ne -\let\@celt\delimiter -\def\NAT@num@list{}% -\def\NAT@cite@list{}% -\def\NAT@nonsort@list{}% -\@for \@citeb:=#1\do{\NAT@make@cite@list}% -\protected@edef\NAT@cite@list{\NAT@cite@list\NAT@nonsort@list}% -\protected@edef\NAT@cite@list{\expandafter\NAT@xcom\NAT@cite@list @@}} -\begingroup \catcode`\_=8 -\gdef\NAT@make@cite@list{% - \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% - \@ifundefined{b@\@citeb\@extra@b@citeb}{\def\NAT@num{A}}% - {\NAT@parse{\@citeb}}% - \ifcat _\ifnum\z@<0\NAT@num _\else A\fi - \@tempcnta\NAT@num \relax - \ifnum \@tempcnta>\@tempcntb - \protected@edef\NAT@num@list{\NAT@num@list \@celt{\NAT@num}}% - \protected@edef\NAT@cite@list{\NAT@cite@list\@citeb,}% - \@tempcntb\@tempcnta - \else - \let\NAT@@cite@list=\NAT@cite@list \def\NAT@cite@list{}% - \protected@edef\NAT@num@list{\expandafter\NAT@num@celt \NAT@num@list \@gobble @}% - {\let\@celt=\NAT@celt\NAT@num@list}% - \fi - \else - \protected@edef\NAT@nonsort@list{\NAT@nonsort@list\@citeb,}% - \fi} -\endgroup -\def\NAT@celt#1{\ifnum #1<\@tempcnta - \xdef\NAT@cite@list{\NAT@cite@list\expandafter\NAT@nextc\NAT@@cite@list @@}% - \xdef\NAT@@cite@list{\expandafter\NAT@restc\NAT@@cite@list}% - \else - \xdef\NAT@cite@list{\NAT@cite@list\@citeb,\NAT@@cite@list}\let\@celt\@gobble% - \fi} -\def\NAT@num@celt#1#2{\ifx \@celt #1% - \ifnum #2<\@tempcnta - \@celt{#2}% - \expandafter\expandafter\expandafter\NAT@num@celt - \else - \@celt{\number\@tempcnta}\@celt{#2}% - \fi\fi} + \let\NAT@cite@list\@empty + \@for\@citeb:=#1\do{\expandafter\NAT@star@cite\@citeb\@@}% + \if@filesw + \expandafter\immediate\expandafter\write\expandafter\@auxout + \expandafter{\expandafter\string\expandafter\citation\expandafter{\NAT@cite@list}}% + \fi + \@ifnum{\NAT@sort>\z@}{% + \expandafter\NAT@sort@cites@\expandafter{\NAT@cite@list}% + }{}% +}% +\def\NAT@star@cite{% + \let\NAT@star@sw\@secondoftwo + \@ifnum{\NAT@merge>\z@}{% + \@ifnextchar*{% + \let\NAT@star@sw\@firstoftwo + \NAT@star@cite@star + }{% + \NAT@star@cite@nostar + }% + }{% + \NAT@star@cite@nostar + }% +}% +\def\NAT@star@cite@star*{% + \NAT@star@cite@nostar +}% +\def\NAT@star@cite@nostar{% + \let\nat@keyopt@open\@empty + \let\nat@keyopt@shut\@empty + \@ifnextchar[{\NAT@star@cite@pre}{\NAT@star@cite@pre[]}% +}% +\def\NAT@star@cite@pre[#1]{% + \def\nat@keyopt@open{#1}% + \@ifnextchar[{\NAT@star@cite@post}{\NAT@star@cite@post[]}% +}% +\def\NAT@star@cite@post[#1]#2\@@{% + \def\nat@keyopt@shut{#1}% + \NAT@star@sw{\expandafter\global\expandafter\let\csname NAT@b*@#2\endcsname\@empty}{}% + \NAT@cite@list@append{#2}% +}% +\def\NAT@cite@list@append#1{% + \edef\@citeb{\@firstofone#1\@empty}% + \if@filesw\@ifxundefined\@cprwrite{}{\expandafter\@cprwrite\@citeb=}\fi + \if\relax\nat@keyopt@open\relax\else + \global\expandafter\let\csname NAT@b@open@\@citeb\endcsname\nat@keyopt@open + \fi + \if\relax\nat@keyopt@shut\relax\else + \global\expandafter\let\csname NAT@b@shut@\@citeb\endcsname\nat@keyopt@shut + \fi + \toks@\expandafter{\NAT@cite@list}% + \ifx\NAT@cite@list\@empty + \@temptokena\expandafter{\@citeb}% + \else + \@temptokena\expandafter{\expandafter,\@citeb}% + \fi + \edef\NAT@cite@list{\the\toks@\the\@temptokena}% +}% +\newcommand\NAT@sort@cites@[1]{% + \count@\z@ + \@tempcntb\m@ne + \let\@celt\delimiter + \def\NAT@num@list{}% + \let\NAT@cite@list\@empty + \let\NAT@nonsort@list\@empty + \@for \@citeb:=#1\do{\NAT@make@cite@list}% + \ifx\NAT@nonsort@list\@empty\else + \protected@edef\NAT@cite@list{\NAT@cite@list\NAT@nonsort@list}% + \fi + \ifx\NAT@cite@list\@empty\else + \protected@edef\NAT@cite@list{\expandafter\NAT@xcom\NAT@cite@list @@}% + \fi +}% +\def\NAT@make@cite@list{% + \advance\count@\@ne + \@safe@activestrue + \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}% + \@safe@activesfalse + \@ifundefined{b@\@citeb\@extra@b@citeb}% + {\def\NAT@num{A}}% + {\NAT@parse{\@citeb}}% + \NAT@ifcat@num\NAT@num + {\@tempcnta\NAT@num \relax + \@ifnum{\@tempcnta<\@tempcntb}{% + \let\NAT@@cite@list=\NAT@cite@list + \let\NAT@cite@list\@empty + \begingroup\let\@celt=\NAT@celt\NAT@num@list\endgroup + \protected@edef\NAT@num@list{% + \expandafter\NAT@num@celt \NAT@num@list \@gobble @% + }% + }{% + \protected@edef\NAT@num@list{\NAT@num@list \@celt{\NAT@num}}% + \protected@edef\NAT@cite@list{\NAT@cite@list\@citeb,}% + \@tempcntb\@tempcnta + }% + }% + {\protected@edef\NAT@nonsort@list{\NAT@nonsort@list\@citeb,}}% +}% +\def\NAT@celt#1{% + \@ifnum{#1>\@tempcnta}{% + \xdef\NAT@cite@list{\NAT@cite@list\@citeb,\NAT@@cite@list}% + \let\@celt\@gobble + }{% + \expandafter\def@NAT@cite@lists\NAT@@cite@list\@@ + }% +}% +\def\NAT@num@celt#1#2{% + \ifx#1\@celt + \@ifnum{#2>\@tempcnta}{% + \@celt{\number\@tempcnta}% + \@celt{#2}% + }{% + \@celt{#2}% + \expandafter\NAT@num@celt + }% + \fi +}% +\def\def@NAT@cite@lists#1,#2\@@{% + \xdef\NAT@cite@list{\NAT@cite@list#1,}% + \xdef\NAT@@cite@list{#2}% +}% \def\NAT@nextc#1,#2@@{#1,} \def\NAT@restc#1,#2{#2} \def\NAT@xcom#1,@@{#1} -\else - \newcommand\NAT@sort@cites[1]{\protected@edef\NAT@cite@list{#1}}\fi \InputIfFileExists{natbib.cfg} {\typeout{Local config file natbib.cfg used}}{} %% |