I have seen multiple posts what "nice" formats one might use for bibtex citation keys as in
@ARTICLE{ FormatInQuestion,
author = {XXX},
title = {YYY},
}
My question is different, and arises when doing
bibtool --preserve.key.case=on --preserve.keys=on refs.bib > refs_new.bib
where I get
@article{ doi:10.1016/s0012-365x(97)00126-x,
_________________________________^
*** BibTool ERROR: (line 2101 in ./references.bib): Unexpected character encountered
so even though I ask bibtool to not change the citations keys whatsoever, it complains about having an opening parenthesis (
in the key.
My question is
What format is formally allowed to be used for the citation key "FormatInQuestion"?
As an example, I expect that only a closing parenthesis FormatInQuestion
= }
is probably not allowed. Is that correct?
Best Answer
I've made a few experiments.
Braces are not allowed. If in initial position they're dropped by the LaTeX argument scanner, in middle position they cause BibTeX to fail
A comma is obviously disallowed, being the field separator.
The backslash, even escaped, is not allowed because of obvious TeXnical issues.
The percent is not allowed for similar reasons.
Other characters might be dangerous in LaTeX contexts, like double punctuation when French
babel
is active or straight quotes for severalbabel
languages.The citation key should consist of printable ASCII characters (with the above mentioned exceptions).
The following
.bib
filein a non
babel
document produces the following.bbl
fileOn the other hand, running
bibtool
on the.bib
file with the same options as you have in the question producesSo I conclude that the error raised by BibTool is a decision by the programmer (possibly induced by the usage of Perl for the string management).