summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/natbib
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-02-03 01:27:50 +0000
committerKarl Berry <karl@freefriends.org>2009-02-03 01:27:50 +0000
commit7da0c3762d07bfc8387027a844b9372302d48f03 (patch)
tree64ce00c41d51e48dcbfa6a737cb710aaf6566d69 /Master/texmf-dist/tex/latex/natbib
parentb396e9795f300708e4296019397ba084a1a37ace (diff)
natbib 83 (2feb09)
git-svn-id: svn://tug.org/texlive/trunk@12056 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/natbib')
-rw-r--r--Master/texmf-dist/tex/latex/natbib/natbib.sty984
1 files changed, 663 insertions, 321 deletions
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}}{}
%%