2

Q: how do I set a specific separator in bibtex-mode's autokey generator?

Background

I am working with bibtex-mode. It has a feature to auto-generate the entry key, which is customizable.

Goal

My goal is to get the autokey to work as follows:

  • One author: authorname:year.
  • Two authors: authorname1-authorname2:year.
  • Three or more authors: authorname1-etal:year.

Almost There

The following settings almost get me there:

(setf bibtex-autokey-additional-names "etal"
      bibtex-autokey-name-separator "-"
      bibtex-autokey-name-year-separator ":"
      bibtex-autokey-year-length 4
      bibtex-autokey-names 1
      bibtex-autokey-names-stretch 1
      bibtex-autokey-titlewords 0)

The Specific Problem

It works for one and two authors. However, for three or more authors, the generated key is:

authorname1etal:year

rather than the desired, hyphen-separated

authorname1-etal:year

How do I get the hyphen separator between the author name and the etal?

Examples

@Article{,
  author       = {Bob Smith},
  title        = {A title},
  journal      = {A journal},
  year         = 2014
}

produces smith:2014

@Article{,
  author       = {Bob Smith and Frank Jones},
  title        = {A title},
  journal      = {A journal},
  year         = 2015
}

produces smith-jones:2015

@Article{,
  author       = {Bob Smith and Frank Jones and Joe Johnson},
  title        = {A title},
  journal      = {A journal},
  year         = 2016
}

produces smithetal:2016 (and I want smith-etal:2016)

2

Would the simple, if slightly barbaric, solution of setting bibtex-autokey-additional-names to "-etal", (with a hyphen built-in), work for you?

It has the advantage that you don't have to source-dive or modify any of the elisp functions.

  • 1
    Oiy, yes, that works just fine. The autokey machinery is so intricate that I was searching around for the right nob to adjust, and it never occurred to me that there was a very simple answer available. Thanks! – Dan Jul 18 '17 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.