Monday, August 15, 2011

Natbib's Same Name Problem

When working yesterday on my book on Frege's Grundgesetze, I suddenly realized that I had a problem with the bibliography. I have references to papers written by both Charles Parsons and Terence Parsons, one each from 1995. These were coming out in the citations as: (Parsons, 1995a) and (Parsons, 1995b). These are at least unambigious, but they are not what one would want. And, indeed, even if I hadn't had papers published the same year, I'd still be getting: (Parsons, 1965) and (Parsons, 1995), which still isn't what I'd want. What I'd want is: (Parsons, C., 1965) and (Parsons, T., 1995).

Googling turned up several complaints about this, which I would characterize as a bug in the LaTeX package natbib, that being what has traditionally been used with LaTeX for author-year references. Many people now are using biblatex, of course, and perhaps this bug has been resolved there. But I already have a custom bibliography style written for natbib, so I'm not sure I want to do the work to switch over to biblatex yet, anyway.

So, I got to work to solve the problem. My goal was to modify the standard plainnat.bst style so that it would give me the kinds of citation labels I want. It actually turned out not to be that difficult, given that I've worked before with the strange postfix stack language that is used to write BibTeX styles in developing my own bst file. I've posted the results here:
The former is the modified bst file; the latter is a diff against plainnat.bst, so that you can see exactly what I've done. The changes should be fairly easy to port to other bst's---I hope so, since I still need to port them to my own bst---since they are pretty much confined to one part of the file.

There are limits to the approach. First, I deal only with authors and editors. Second, I deal only with single name cases. But I also provide ways to override the calculated labels, so that you can force a certain label if you need to do so. There are two new entry fields for this purpose:
  1. dupelabel
    Defines a label that will be used if a duplicate author is found, e.g.:
    dupelabel = {Parsons, Ch.}
    dupelabel = {Parsons, Ca.}
    might be put in entries by Christopher Parsons and Carrie Parsons, respectively. 
  2. forcelabel
    Defines the label we will use, period. 

No comments:

Post a Comment

Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.