8

This is my first post on tex.stackexchange, so Hello to everyone.

I am using biblatex with biber to produce the bibliography and I have a problem with utf8 characters. As usual, I can use utf8 characters in the fields, but they do not seem to work when used in the citation key. A mwe is the following:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french,english]{babel}
\usepackage{filecontents}

\begin{filecontents*}{bibliography.bib}
@article{rené,
    author = {Descartes, René},
    title = {Discourse on the method},
}
\end{filecontents*}

\usepackage[backend=biber]{biblatex}
\addbibresource{bibliography.bib}

\begin{document}
This citation fails\cite{rené}.
\printbibliography
\end{document}

I have specified the utf8 encoding but when I run biber (after two compilations with pdflatex) I get the following error:

INFO - This is Biber 2.7 (beta)
INFO - Logfile is 'mwe.blg'
INFO - Reading 'mwe.bcf'
INFO - Found 1 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex format file 'bibliography.bib' for section 0
INFO - Decoding LaTeX character macros into UTF-8
INFO - Found BibTeX data source 'bibliography.bib'
WARN - I didn't find a database entry for 'ren\IeC {\'e}' (section 0)
INFO - Overriding locale 'en-US' defaults 'variable = shifted' with 'variable = non-ignorable'
INFO - Overriding locale 'en-US' defaults 'normalization = NFD' with 'normalization = prenormalized'
INFO - Sorting list 'nty/global/' of type 'entry' with scheme 'nty' and locale 'en-US'
INFO - No sort tailoring available for locale 'en-US'
INFO - Writing 'mwe.bbl' with encoding 'UTF-8'
INFO - Output to mwe.bbl
INFO - WARNINGS: 1

As you can see, the character "é" in the command \cite{rené} has been expanded (by whom?), and therefore biber cannot find the corresponding citation key.

Is there a way to fix this? My keys are automatically generated periodically so I would prefer to avoid the manual editing of every non-ASCII character.

9

You can't use most UTF-8 in the entrykey when you use pdfLaTeX. If you use LuaLaTeX or XeLaTeX, which are both fully UTF-8 compatible out of the box, you can use most UTF-8 characters (amongst them é) in entrykey (some restrictions apply, but those are mostly in the ASCII-range: What is the difference between a biblatex literal and string?, Using BibTeX keys containing parentheses with Biber, What is valid as a BibLaTeX entry key?).

The Biber documentation clearly states

Handles UTF-8 citekeys and filenames (given a suitable fully UTF-8 compliant TeX engine)

but pdfLaTeX is not a Unicode engine. This has to do with how LaTeX internally handles citekeys and characters.

If you are creating the keys automatically, it should be possible to modify the processes such that you get ASCII only. But I find it is much better to come up with the citekeys yourself, that way they are easier to remember, because you already put some thinking into them.

  • 1
    The same limitation seems to hold for traditional BibTeX: How can I insert a special french character in a bibtex cite-key? (but of course BibTeX itself can't handle UTF-8) – moewe Mar 19 '17 at 12:07
  • Jabref can generate or rebuild automatically all keys without tildes based in first author + year from the reference fields as Rene1673 and even Rene1673b and Rene1673b when the two parts are the same in two references. Indeed, the best to start consistently, except if you have already a lot of citations with custom keys (JabRef change only the BiBTeX file). – Fran Mar 20 '17 at 9:03
  • @Fran Does JabRef 'sanitise' the entrykeys such that they only contain ASCII chars? (And nothing stupid like & etc.?) – moewe Mar 20 '17 at 9:11
  • Certainly it can "sanitize" diacritics marks even in LaTeX notation like René, Ren\'e, Ren\'{e} and for extension, any single character command as in Ren\&e, but fail with Ren\&é (will left Ren&e) and some really stupid like \emph{René} will left mphRene , while a simple typo like Re&ne is lelft untouched. But sanitize these keys will not save you of a pretty LaTeX error or worse, a wrongly printed name, so the problem always is sanitize the author field. In practice, I never found a wrong generated key with JabRef. – Fran Mar 20 '17 at 10:04

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.