rgheck wrote:
[EMAIL PROTECTED] wrote:
Hello,
I ran into a strange problem with bibtex while editing my thesis in
Lyx. Maybe it is not really a problem with lyx but I'm no
latex/bibtex expert by far and so maybe users of this list can give
me a hint.
My problem is:
I use author-year citations with my own nat-bib based bibtex style
(created with custombib).
I have two citations from the same author, in the same journal issue
and from the same year. These are made unique by automatically adding
an a or b at the end of the year, e.g.
Knaus (2008) Introduction. Journal. Issue 1. p. 1-12
Knaus (2008) Another new hypothesis. Journal. Issue 1. p. 20-30
should be coverted to
Knaus (2008a) Introduction. Journal. Issue 1. p. 1-12
Knaus (2008b) Another new hypothesis. Journal. Issue 1. p. 20-30
but gets converted to
Knaus (2008b) Introduction. Journal. Issue 1. p. 1-12
Knaus (2008a) Another new hypothesis. Journal. Issue 1. p. 20-30
Probably there is something in the bst file which sorts the addition
of a's and b's according to the alphabetical order of the title which
is generally o.k. but if it's in the same journal issue it should be
sorted numerically according to the pages.
How do I get this? (I have looked into the bst file, but it is so
long ago that I created it...)
Do I have to change something in the .bst file or do I have to add
some special bibtex trick to the preamble of my Lyx file?
It's the bst file that handles this. The presort routine assigns a
sort key to each entry, and then they are sorted according to those
keys. It's a pretty basic routine. What you get is not much more than
author, year, and title, though you get a bit more in some cases.
So you need to fiddle with the presort routine and include the page
numbers in the key. This will be kind of tricky to get, as the obvious
thing to do will get the wrong result with something like: pp. 34-60
vs pp. 124-50. The latter is lexically before the former, so you'd
need to normalize somehow so the former would be "036", or something
like that. (Surely, the end pages don't matter.) You can look at the
n.dashify routine for ideas how to do that.
This kind of thing will work for normalzing...but I've not tested it.
FUNCTION {n.normalize}
{
't :=
t 'save :=
0 'num :=
{ t empty$ not }
{
t #1 #1 substring$ "-" =
{ '' t := }
{
t #1 #1 substring$
t #2 global.max$ substring$ 't :=
num #1 + 'num :=
}
if$
}
while$
#5 'norml :=
{ norml num > }
{ '0' save * 'save := }
while$
save
}