First of all, spaces are not allowed in key names, so we can concentrate on other special characters.
BibTeX
I have prepared the following test file:
@article{a{}b$,
author={A. Uthor},
title={With curly braces and dollar},
journal={Journal},
year=2011,
}
@article{a-b;^,
author={A. Uthor},
title={With hyphen and caret},
journal={Journal},
year=2012,
}
@article{a&#,
author={A. Uthor},
title={With ampersand and hashmark},
journal={Journal},
year=2013,
}
@article{a@_,
author={A. Uthor},
title={With at and underscore},
journal={Journal},
year=2014,
}
@article{a;:",
author={A. Uthor},
title={With semicolon, colon and double quote},
journal={Journal},
year=2015,
}
@article{a?!,
author={A. Uthor},
title={With question and exclamation marks},
journal={Journal},
year=2016,
}
@article{a([)/*],
author={A. Uthor},
title={With parentheses, brackets, slash and asterisk},
journal={Journal},
year=2017,
}
@article{a+='`,
author={A. Uthor},
title={With plus, equals and quotes},
journal={Journal},
year=2018,
}
@article{a.<>,
author={A. Uthor},
title={With period, less and greater},
journal={Journal},
year=2019,
}
and a small test file with a \cite
for each entry. Compiling with LaTeX shows problems for a&#
because of
! Illegal parameter number in definition of \@fortmp.
<to be read again>
}
l.7 \cite{a&#}
which is not really surprising. Going past the two related errors and running BibTeX shows
Stuff after "}"---line 2 of file strange.aux
: \citation{a{
: }b$}
and
Warning--I didn't find a database entry for "a&##"
again not really unexpected. So I conclude that curly braces, even if balanced, and #
are not allowed (but if #
was made of category code 12 in the LaTeX document it would go through).
Now I removed the curly braces and the #
from the relevant keys. The compilation was successful.
Next experiment is to add \usepackage[czech,turkish,ngerman,french]{babel}
to the LaTeX document, which would make several of the characters active, but I got no problem. Note that the .aux
file contains
\catcode `"\active
\catcode `-\active
\catcode `:\active
\catcode `!\active
\catcode `=\active
\catcode `;\active
\catcode `?\active
Next experiment is to have the \cite
commands in the argument to another command, I used \emph
. Again no problem.
Conclusion
The forbidden characters in the seven bit ASCII range are { } , ~ # % \
. I didn't text comma, percent and backslash because they're obviously not acceptable: the first on the BibTeX side, the other two on the LaTeX side.
Also ~
is disallowed (do yourself a test).
Biber
See https://tex.stackexchange.com/a/96918/2388 where it is specified that
" # ' ( ) , = { } %
are disallowed. I guess that also ~
cannot be used (for problems on the LaTeX side like for BibTeX). It goes without saying that the backslash is also out of the question.