7

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?

  • I don't think there are illegal characters for the key, except for (unbalanced) braces, % and backslash. I guess that BibTool is adding some checks on its own. – egreg Oct 22 '16 at 8:04
  • Once more thanks for your quick responce! So @ARTICLE{{}(97), author = {XXX}, title = {YYY} } with key {}(97) is an acceptable format? Do you happen to have any reference to some documentation specifying this? – Christian Oct 22 '16 at 8:09
  • I'm not sure what the legal characters are. I tried looking in the standard sources and found nothing. Oh, obviously the comma! – egreg Oct 22 '16 at 8:10
  • So, any idea how to make bibtool completely ignoring citation keys? – Christian Oct 22 '16 at 8:31
  • Ask the author of BibTool. It's not even distributed in TeX Live, so I can't do experiments; I tried to compile it on my machine, but the instructions are not helpful. – egreg Oct 22 '16 at 8:37
7

I've made a few experiments.

  1. Braces are not allowed. If in initial position they're dropped by the LaTeX argument scanner, in middle position they cause BibTeX to fail

    Stuff after "}"---line 2 of file bibstump.aux
     : \citation{b{ra
     :               }ces}
    I'm skipping whatever remains of this command
    
  2. A comma is obviously disallowed, being the field separator.

  3. The backslash, even escaped, is not allowed because of obvious TeXnical issues.

  4. The percent is not allowed for similar reasons.

  5. Other characters might be dangerous in LaTeX contexts, like double punctuation when French babel is active or straight quotes for several babel languages.

  6. The citation key should consist of printable ASCII characters (with the above mentioned exceptions).

The following .bib file

@article{quo"tes,
  author={A B},
  title={T},
  journal={J},
  year=2000,
}
@article{(paren),
  author={A B},
  title={T},
  journal={J},
  year=2000,
}
@article{o@th[;]er,
  author={A B},
  title={T},
  journal={J},
  year=2000,
}

in a non babel document produces the following .bbl file

\begin{thebibliography}{1}

\bibitem{quo"tes}
A~B.
\newblock T.
\newblock {\em J}, 2000.

\bibitem{(paren)}
A~B.
\newblock T.
\newblock {\em J}, 2000.

\bibitem{o@th[;]er}
A~B.
\newblock T.
\newblock {\em J}, 2000.

\end{thebibliography}

On the other hand, running bibtool on the .bib file with the same options as you have in the question produces

@article{quo"tes,
_____________^
*** BibTool ERROR:  (line 1 in ./bibstump.bib): Unexpected character encountered

*** BibTool WARNING: Skipping to next '@'

*** BibTool WARNING:  (line 7 in ./bibstump.bib): 49 non-space characters ignored.

@article{(paren),
________________^
*** BibTool ERROR:  (line 7 in ./bibstump.bib): Unexpected character encountered

*** BibTool WARNING: Skipping to next '@'

*** BibTool WARNING:  (line 13 in ./bibstump.bib): 46 non-space characters ignored.

So 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).

  • 1
    Perhaps note that BibTeX(8) requires the key to be 7-bit, even though other parts of the file can be 'passed through' as UTF-8 or whatever (if not processed by BibTeX). – Joseph Wright Oct 22 '16 at 9:18
  • @JosephWright I considered that as obvious, but I'll add it. – egreg Oct 22 '16 at 9:21
  • Don't think it is, as like I say you can use UTF-8 happily in the bulk of a file if there is no case-changing or whatever in the .bst. – Joseph Wright Oct 22 '16 at 9:22

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.