You remark,
I was working with ... \begin{thebibliography}
, and I had spaces in the ids, and there seemed to be no problem.
If one uses
\begin{thebibliography}{99}
...
\bibitem{some key} ...
...
\end{thebibliography}
to create the formatted bibliography, one is not only formatting the bibliographic entries by hand, one is also performing the selection of which entries should show up in the formatted bibliography by hand. As such, having a space in the argument of \bibitem
, though by no means encouraged, does not appear to be fatal.
In contrast, if one uses an external program (e.g., bibtex or biber) to create the formatted bibliography, the external program has to rely on the arguments of the various \cite
commands to determine which entries need to be extracted from the bib file(s). In order to make this determination successful and unambiguous, the bib entries and their fields must satisfy various lexical rules. One of them is that no whitespace is allowed in the name of the key of a bibliographic entry. This isn't an arbitrary choice. BibTeX and Biber allow whitespace both before and after the key. E.g.,
@misc{ab:2000,
@misc{ ab:2000 ,
are both semantically valid and, indeed, would be considered to have the same key. In contrast, if whitespace were allowed in the interior of the key's name, then
@misc{cd 2010,
@misc{ cd 2010,
@misc{cd 2010 ,
@misc{ cd 2010 ,
could conceivably constitute the beginnings of four separate and distinct entries. To keep the scope for typographic confusion at least somewhat manageable, one would have to disallow whitespace both before and after the key in order to allow whitespace inside the key name. What you lose on the swings, you gain on the roundabouts...
It's worth keeping in mind that BibTeX (the program) has been around for more than 35 years. When BibTeX was first launched, programs to perform lexical analysis were far less powerful than they are today. In my view, Oren Patashnik (the creator of BibTeX) acted wisely by not allowing whitespace in the interior of bibliographic keys, as this simplification freed up some much-needed time to address other, far more pressing software-related issues.
@article{key, ... }
? Please clarify. – Mico Oct 4 '20 at 7:46.bib
file). You will have to remove them, sorry. – moewe Oct 4 '20 at 12:13