[texhax] NatBib-based styles and unusual year or author entries
Dan Hatton
vi5u0-texhax at yahoo.co.uk
Fri Jun 1 18:34:43 CEST 2007
On Wed, 30 May 2007, Philip G. Ratcliffe wrote:
> However, if I enclose the entire date in an extra set of braces {}
> then, on runnng LaTeX, I get a string of errors, but ... the output
> is correct.
Dear All,
I have some more information on this. I was originally getting the
wrong output, McGlashan 1995 (1911) b,( instead of McGlashan 1995(
1911) b,a because this construction in natbib.sty:
\newcommand\NAT at parse@date{}
\def\NAT at parse@date#1#2#3#4#5#6@@{%
\ifnum\the\catcode`#1=11\def\NAT at year{}\def\NAT at exlab{#1}\else
\ifnum\the\catcode`#2=11\def\NAT at year{#1}\def\NAT at exlab{#2}\else
\ifnum\the\catcode`#3=11\def\NAT at year{#1#2}\def\NAT at exlab{#3}\else
\ifnum\the\catcode`#4=11\def\NAT at year{#1#2#3}\def\NAT at exlab{#4}\else
\def\NAT at year{#1#2#3#4}\def\NAT at exlab{{#5}}\fi\fi\fi\fi}
assumes that, if the construct like "1995a" or "1995 (1911)a" has more
than four tokens, the fifth token is the citation letter (a, b, etc.,)
and uses it as such (it's a sort of very long-term millenium bug,
whereby natbib will fail in the year 10000.) So, Philip's trick of
enclosing the whole year construct in parentheses, year="{1995
(1911)}", gave the correct output, because it reduced the number of
tokens in the year to 1 <= 4. It produced error messages (I guess)
because the catcode of a multi-character token is non-numeric, so
\ifnum can't cope with it.
One solution would be to make a version of natbib.sty with something
like
\newcommand\NAT at parse@date{}
\def\NAT at parse@date#1#2#3#4#5#6#7#8#9#10#11#12#13@@{%
\ifnum\the\catcode`#1=11\def\NAT at year{}\def\NAT at exlab{#1}\else
\ifnum\the\catcode`#2=11\def\NAT at year{#1}\def\NAT at exlab{#2}\else
\ifnum\the\catcode`#3=11\def\NAT at year{#1#2}\def\NAT at exlab{#3}\else
\ifnum\the\catcode`#4=11\def\NAT at year{#1#2#3}\def\NAT at exlab{#4}\else
\ifnum\the\catcode`#5=11\def\NAT at year{#1#2#3#4}\def\NAT at exlab{#5}\else
\ifnum\the\catcode`#6=11\def\NAT at year{#1#2#3#4#5}\def\NAT at exlab{#6}\else
\ifnum\the\catcode`#7=11\def\NAT at year{#1#2#3#4#5#6}\def\NAT at exlab{#7}\else
\ifnum\the\catcode`#8=11\def\NAT at year{#1#2#3#4#5#6#7}\def\NAT at exlab{#8}\else
\ifnum\the\catcode`#9=11\def\NAT at year{#1#2#3#4#5#6#7#8}\def\NAT at exlab{#9}\else
\ifnum\the\catcode`#10=11\def\NAT at year{#1#2#3#4#5#6#7#8#9}\def\NAT at exlab{#(10)}\else
\ifnum\the\catcode`#11=11\def\NAT at year{#1#2#3#4#5#6#7#8#9#10}\def\NAT at exlab{#11}\else
\def\NAT at year{#1#2#3#4#5#6#7#8#9#10#11}\def\NAT at exlab{{#12}}\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
but that's not permissible due to having more than nine parameters.
Anyone have any better ideas, please?
--
Thanks
Dan Hatton
More information about the texhax
mailing list