I have a citation style problem that I think I can't solve with natbib (i.e.,
with \bibpunct or \bibstyle@bst).
I am using natbib with apsr.bst, one of the .bst files included with the
harvard package. (I'm not using the harvard package, though.) The style file
currently produces citations like
Hastie and Park, 1986
Lodge, Steenbergen and Brau, 1995
I need something slightly different:
Hastie and Park, 1986
Lodge, Steenbergen, and Brau, 1995
In other words, I need a comma before " and" -- but only when there are more
than two authors in the citation.
This seems beyond natbib, so I want to edit the .bst file. This is the
function in the file that governs citation style:
FUNCTION {format.lab.names.full} { 's :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr "{vv~}{ll}" format.name$ 't :=
nameptr #1 >
{ namesleft #1 >
{ ", " * t * }
{ t "others" =
{ " et~al." * }
{ " \harvardand\ " * t * }
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
I thought that this would be easy to edit. I would just append another while$
loop, identical to the one here except that " \harvardand\ " would be replaced
by ", \harvardand\ ". An if$ loop (on condition { numnames #2 > }) would
determine which while$ loop was run.
I tried that. It didn't work. For every bibliography entry that I
cited, BibTeX told me that `'118' is a function literal, not a string'. I
don't know what that means.
How should I edit the format.lab.names.full function?
Thank you,
--John Bullock
nothing to do with natbib, really.
ah. you want us to redo all your work.
i would be more inclined to investigate further if i could see your
failed attempt: i've worked in this area of a .bst file in the past
... but "past" in this case means "in 1995", and i don't want to start
again.
--
Robin Fairbairns, Cambridge
It's been awhile since I've tried to decipher a .bst file precisely, but
at first glance it looks to me as if you don't need to edit the .bst
file at all -- just \renewcommand{\harvardand}{, and}. Adding a new
while$ loop is just asking for trouble.
I don't have harvard installed on my system, though, so I haven't tested
this.
I didn't include it because it was several ugly screenfuls of code -- and I
thought it wouldn't help. But I am appending a more succinct attempt that
seems to do the trick. The modification to the original format.lab.names.full
lies in the change of
{ " \harvardand\ " * t * }
to
{ numnames #2 >
{ ", \harvardand\ " * t * }
{ " \harvardand\ " * t * }
if$
}
--John
FUNCTION {format.lab.names.full} { 's :=
#1 'nameptr :=
s num.names$ 'numnames :=
numnames 'namesleft :=
{ namesleft #0 > }
{ s nameptr "{vv~}{ll}" format.name$ 't :=
nameptr #1 >
{ namesleft #1 >
{ ", " * t * }
{ t "others" =
{ " et~al." * }
{ numnames #2 >
{ ", \harvardand\ " * t * }
{ " \harvardand\ " * t * }
if$
}
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
}
"Robin Fairbairns" <r...@cl.cam.ac.uk> wrote in message
news:drvee3$n8p$2...@gemini.csx.cam.ac.uk...