TransWikia.com

Colon in bibtextkey

TeX - LaTeX Asked on August 1, 2020

I always use colons when denoting items in my bibliography (in a .bib file):
Lee:05, Smith:11, etc.

However, Jabref says that

Some characters should not be used in bibtexkey as they are not compatible or not recommended:
{ } ( ) , " – # ~ ^ : ‘ (note the colon!)

What’s the problem with the colon? Should I expect to have some issues with my bibliography because of that?

One Answer

There are two aspects to asking whether a character is safe in entry keys.

  1. The character needs to be safe when it is read by BibTeX (or Biber) in the .bib file.
  2. The character needs to be safe when it is later processed by LaTeX.

Examples of characters that are unsafe on the .bib side would be ,, =, { and }. Those characters have special meaning in the .bib file syntax and cannot be used in entry keys as that would confuse BibTeX or Biber when they parse the .bib file.

One example of an unsafe character on the LaTeX side is ~. ~ is absolutely fine on the .bib file side, but it has a special definition for LaTeX (inserting a non-breakable space). The following MWE therefore breaks

documentclass{article}
usepackage{natbib}

begin{filecontents}{jobname.bib}
@book{appleby~1980,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  year    = {1980},
}
end{filecontents}

begin{document}
cite{appleby~1980}
bibliographystyle{plainnat}
bibliography{jobname}
end{document}

(Note that biblatex can accept entry keys with ~.)


The : is not problematic on the .bib side of things, since : does not have a special meaning in the .bib file syntax.

Depending on your language settings, : either behaves as normal or has a special definition (e.g. in French). If the colon has a special definition, it is potentially dangerous. But all bibliography and citation setups that I tested (of course I only tested the usual ones) take precautions against problems with :, so the following MWE compiles fine.

documentclass[french]{article}
usepackage[T1]{fontenc}
usepackage{natbib}
usepackage{babel}

begin{filecontents}{jobname.bib}
@book{appleby:1980,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  year    = {1980},
}
end{filecontents}

begin{document}
cite{appleby:1980}
bibliographystyle{plainnat}
bibliography{jobname}
end{document}

A similar example also works fine with biblatex. Indeed, the biblatex examples file biblatex-examples.bib makes ample use of colons in entry keys.

However, the occasional problem with colons pops up from time to time, see leandriis' link Colon in bibliography keys incompatible with babel, biblatex and tex4ht.

Correct answer by moewe on August 1, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP