3

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}
}
  • Does \c{e} make any sense at all? – egreg May 27 '16 at 14:09
  • 1
    can you show us the word in which the \c{e} occurs? – barbara beeton May 27 '16 at 14:18
  • Have you tried {\c e}, i.e., leaving off the inner pair of curly braces? – Mico May 27 '16 at 14:19
  • original problematic bibtex entry added – KIAaze May 27 '16 at 15:42
  • 1
    The web page shows Sęk, so it should be S{\k{e}}k. It's obviously a bug of Mendeley. – egreg May 27 '16 at 15:51
6

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

  • 1
    Good answer, but it's conceptually wrong to use \c{e} when quite likely \k{e} is intended. If \c{e} is output by Mendeley, then this software is at fault and should be fixed. – egreg May 27 '16 at 14:35
  • @egreg: Well if the intended glyph has an unicode position then Mendeley should simply output the glyph. (And for accented chars which exist only as char + combining accents it should probably offer some configurable table). – Ulrike Fischer May 27 '16 at 14:45
  • @egreg Damn. Actually it wasn't the combining accent but U+0229 is simply not declared. – Ulrike Fischer May 27 '16 at 14:58
  • Thanks a lot. I used the --output-safechars, because I don't want to manually fix each bibtex entry. Although if there are not too many problematic entries and it always corresponds to actual Mendeley errors, I might still manually fix them... At least everything compiles for now. – KIAaze May 27 '16 at 17:06
0

I'd like to point out it all works fine with xelatex, as long as the font contains all characters. It seems lmodern doesn't have the ȩ. Demonstration with lmodern (the default with xelatex, and erewhon (an extension of Adobe Utopia):

\documentclass{report}
\usepackage{fontspec}
\setmainfont{erewhon}
\usepackage{csquotes} \usepackage[backend=biber]{biblatex}

\addbibresource{special.bib}

\begin{document}
text:

ç
ę
ą
ô
ȩ

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

Bib file:

@article{foo2016, title = {{title}}, author = {
  ç
  ę\k{e}
  ą\k{a}
  ô
  ȩ\c{e}
}, }

Result with lmodern:

enter image description here

Result with erewhon:

enter image description here

  • I switched to biber because of unicode troubles until I stumbled onto this problem. So maybe using xelatex or lualatex might be worth it at some point. How easy is it to switch from pdflatex to xelatex or lualatex? (especially if I currently use lyx and all kinds of packages for tables, pgfplots, etc, svg pictures included via lyx) – KIAaze May 27 '16 at 17:15
  • You might have problems only with packages specifically designed for pdflatex. The point you must have utf8 encoded source files. You have to remove the calls to inputenc and fontenc since it uses the truetype of opentype fonts directly. Also you have to load fontspec and use declarations like \setmainfont{…} (the default is Latin Modern). Last point: microtype is not fully functional with xelatex, in particular letterspacing (but the opentype format has its own mechanism). – Bernard May 27 '16 at 17:21
  • Just to point out that the letterspacing functionality of microtype can be achieved, quite closely if not fully, with fontspec's LetterSpace feature. – Juan del Acebo Dec 15 '16 at 15:21

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.