The problem is the supplementary pair of braces, which is however necessary for correct sorting. You should try biblatex
, really, because it provides different fields for sorting dates.
A possible patch is to write, after loading natbib
,
\makeatletter
\let\NAT@bare@aux\NAT@bare
\def\NAT@bare#1(#2){%
\begingroup\edef\x{\endgroup
\unexpanded{\NAT@bare@aux#1}(\@firstofone#2)}\x}
\makeatother
This will swallow the offending part, while keeping the correct sorting order.
The problem is in what's presented to LaTeX and natbib
to interpret. If you look at the .bbl
file, you'll see that the entry starts with
\bibitem[Knuth({\noopsort{1973c}}1981)]{book-full}
Now natbib
uses this to produce the results from \citep{book-full}
(or \citet
), by applying various commands. The relevant one (that I found with some grep
search) is \NAT@bare
that requires its arguments in the form
\def\NAT@bare#1(#2)#3(@)#4\@nil#5{%
The relevant part is #1(#2)
, which is derived from the argument to \bibitem
in brackets; natbib
wants to perform a numeric check, assuming that what's in parentheses is the year. But it finds {\noopsort{1973c}}1981
and this breaks off. So I make an alias to the original \NAT@bare
command, calling it \NAT@bare@aux
and do
\def\NAT@bare#1(#2){%
\begingroup\edef\x{\endgroup
\unexpanded{\NAT@bare@aux#1}(\@firstofone#2)}\x}
So, when natbib
wants to execute \NAT@bare
(it's so instructed by other macros), it will take the argument Knuth({\noopsort{1973c}1981}) and perform an
\edef; thus
\x` will be defined as the result of completely expanding
\endgroup\unexpanded{\NAT@bare@aux Knuth}(\@firstofone{\noopsort{1973c}}1981)
The job of \@firstofone
is just to strip the braces, and the expansion of \noopsort{1973c}
is just empty. So at the end LaTeX will see
\NAT@bare@aux Knuth(1981)
which is in the right format. The \endgroup
balances the \begingroup
and vanishes together with the definition of \x
which has already done its job.
If the entry is normal, say \bibitem[Author(2012)]
(by the way, Happy New Year), \x
will be defined as the full expansion of
\endgroup\unexpanded{\NAT@bare@aux Author}(\@firstofone 2012)
and \@firstofone 2
will simply return 2
, so in the end LaTeX will see
\NAT@bare@aux Author(2012)
as it should.
Best Answer
Since it appears that you want to have citations in sorted&compressed numeric-superscript mode, you could load the
cite
package with thesuperscripts
option:The options
sort
andcompress
are "true" by default with thecite
package.Of course, if you load the
cite
package, do not loadnatbib
as well.