[Tex/LaTex] Using \c{e} and other special characters in .bib files with pdflatex+biblatex+biber: How to avoid Package inputenc Error

biberbiblatexinput-encodingspdftex

I use Mendeley to manage my bibliography and have it automatically update .bib files. Unfortunately, this often leads to the "Package inputenc Error" when compiling.

I narrowed my problem down to this MWE (well non-working, but working with removal of \c{e} in .bib):

special.tex :

\documentclass{report}
\usepackage[T1]{fontenc} % necessary for "old text encoding" apparently (like for \k{a} (ogonek used in Polish))
\usepackage[utf8]{inputenc}
\usepackage[backend=biber]{biblatex}

\addbibresource{special.bib}

\begin{document}
  text:

  \c{c}
  \k{e}
  \k{a}
  \^{o}
  \c{e}

  \cite{foo2016}
  \printbibliography
\end{document}

special.bib :

@article{foo2016,
title = {{title}},
author = {
  \c{c}
  \k{e}
  \k{a}
  \^{o}
  \c{e}
},
}

problematic characters:
{\c{e}}

I compile with:

pdflatex special.tex
biber special
pdflatex special.tex

When \c{e} is removed from the bib entry, compilation works, despite the same character being present in the .tex file and rendering without issues in the main text.

While I could probably just use \k{e} here, which works, this is only one of many entries, which regularly get messed up whenever I do a DOI lookup in Mendeley or similar. I would prefer not to worry about encoding issues at all if possible.

Versions:

  • biber: v1.9
  • pdflatex: pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014/Debian)
  • biblatex: v2.9a

(but I had the same issue on ubuntu 16.04 with more recent packages, although I cannot test there at the moment)

edit:
Here is the full entry as generated by DOI lookup in Mendeley (I created a new entry to make sure it's not my own fault):

@article{new_test_entry,
author = {Reithmaier, J. P. and S{\c{e}}k, G. and L{\"{o}}ffler, A. and Hofmann, C. and Kuhn, S. and Reitzenstein, S. and Keldysh, L. V. and Kulakovskii, V. D. and Reinecke, T. L. and Forchel, A.},
doi = {10.1038/nature02969},
issn = {0028-0836},
journal = {Nature},
mendeley-groups = {Personal},
month = {nov},
number = {7014},
pages = {197--200},
title = {{Strong coupling in a single quantum dot–semiconductor microcavity system}},
url = {http://www.nature.com/doifinder/10.1038/nature02969},
volume = {432},
year = {2004}
}

Best Answer

biber will (not always but quite often) convert an accent command to the decomposed unicode representation "char + combining accent". But pdflatex can't handle combining accents. So as long as you are using pdflatex you must avoid that this happens.

To do this you can

  • tell biber not to output everything in utf8 with --output-safechars and similar options
  • or input in the bib directly the correct utf8 char, in your case LATIN SMALL LETTER E WITH CEDILLA' (U+0229) as ȩ. Sometimes you will have to add definitions for such chars.
  • or if you want to use commands in the bib, fool biber by using a different name, e.g. \cedilla{e}, and in your document do \let\cedilla\c. But be aware that biber then no longer can recognize the intended glyph and so sorting can be wrong.

Edit:

Actually this here is one of the case where biber doesn't output a combining accent. The problem is simply that U+0229 is not declared. One only needs to add \DeclareUnicodeCharacter{0229}{\c{e}} and \c{e} in the bib will work.

To demonstrate the last two advice. This bib-file

@article{foo2016,
title = {{title}},
author = {
  \c{c}
  \k{e}
  \k{a}
  \^{o}
  \cedilla{e}
  ȩ
},
}

with this document

\documentclass{report}
\usepackage[T1]{fontenc} % necessary for "old text encoding" apparently (like for \k{a} (ogonek used in Polish))
\usepackage[utf8]{inputenc}
\usepackage[backend=biber]{biblatex}

\addbibresource{special.bib}

\newcommand\cedilla{}
\let\cedilla\c
\DeclareUnicodeCharacter{0229}{\c{e}}
\begin{document}
  \cite{foo2016}
  \printbibliography
\end{document}

will give this result

enter image description here

Related Question