Add dash between last names in citation key

Hi,

I am looking for a way to customize the citation key.
What I want is something like Alice-Bob-Cameron_93 for a paper by Alice, Bob and Cameron in the year of 1993. I hope this list will cover last name of all authors.

I know that [authors] will generate all last name of all authors, but I could not find a way to add dash between them.

I am not sure if this is possible, but if it is, I’d very appreciate some help as to how to do it!

Thanks!

I am using the newest development version of JabRef.

I have not found a way to make use of [authors].

Choosing from the author related field makers and other field markers and using a regex pattern, it is possible to craft [auth.etal:regex("\.","-"):regex("-etal","")]\_[shortyear], which yields exactly what you want with one or two authors, but if you have more than two, those will be truncated.

Koppor has raised a new PR here that will allow - by default.
By the way, in the newest development version, one only has to use one backslash for regex patterns. In 5.x versions, one had to use two backslashes.

It should work with [authors:regex("(.)([A-Z])","$1-$2")]_[shortyear].

Explanation: Use all llastnames of all authors; they are concatenated with capital letters. Then replace all lower letter followed by them, but add a “-” inbetween. – I think, this does not work with dashed names, but maybe better then nothing for now?

To have this working, - needs to be kept:

While biblatex - What characters are allowed to use as delimiters for BibTeX keys? - TeX - LaTeX Stack Exchange argues there should be nothing wrong with using - and _ in your citationkeypattern, the following resources point to possible conflicts but I don’t know if this is still up to date or if the ecosystem has fixed this with the move towards UTF8:

Could you please report, if you encounter any problems in daily usage?

The hyphen must not be among the “Remove the following characters” list but can still be removed selectively from within author names without affecting the separator between different names. Here is a regex to do it.

[authors:regex("\W*(\w+?)(?=[A-Z])","$1-")]_[shortyear]

Explanation:

  1. Find 0 or more non-word characters
  2. followed by 1 word-character
  3. and as many additional word-characters as needed (but no more)
  4. until but the next character coming up is in uppercase [A-Z] (but not including the uppercase character).
  5. Drop non-word characters, if any, from the beginning of the match (to remove hyphens and any other non-word characters within names).
  6. Keep the remaining word characters (the author name) and add - at the end of each match (to delineate author names).
  7. Add _ and shortyear after the list of delineated names.

Example: Nazzal, Sharif Q. and Al-Dubai, Mohammed and Mounir, Ragia and Ali, Sherif and Mounir, Mohamed

becomes

Nazzal-AlDubai-Mounir-Ali-Mounir_21

Notice that “Al-Dubai” has changed to “AlDubai”, making it impossible to mistake the hyphenated name for two different author-names, while new dashes have been inserted between each of the author name.

Note that the regex is still incomplete, because the set [A-Z] does not match accented characters such as Ü É and Ô.

@Yunfan_He, you can add ranges of additional characters, if you are familiar with them. Alternatively, you can add individual characters this way as you discover imperfections in the citationkey expression:

[authors:regex("\W*(\w+?)(?=[A-ZÜÉÔ])","$1-")]_[shortyear]

Edit: Note that if the name contains more than one occurrence of non-word + word characters, the expression will only replace the last. The “Remove the following characters” option will take care of non-hyphens, but the expression will only remove the last hyphen in a multi-hyphenated name. Mixed cases also pose a challenge. Here are some examples.

O'Brien-MacDonald, Alice and Double-Hyphen-Me, Bob and O'Connor-Callahan, Cameron