4

Biblatex works fine with pdflatex, but when compiling with Xelatex, suddenly accents disappear.

MWE:

\documentclass{article}

\usepackage[
backend=biber,
style=alphabetic,
citestyle=authoryear 
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{temp.bib}
    @article{Beck_Johnson_2013,
        title               ={The Effect of Temperature on \textit{{Anopheles}} Mosquito Population},
        author              ={Bj{\' o}rnstad, Ottar N.},
        year                ={2013},
        journaltitle        ={PLOS ONE}
    }
\end{filecontents*}

\addbibresource{temp.bib}

\begin{document}

\cite{Beck_Johnson_2013}

\printbibliography
\end{document}

With Xelatex: No accents

With Pdflatex: Accents

5

Xe(La)TeX uses Computer Modern as default typeface. Computer Modern does not contain real accented characters, they can be composed of several characters via macros instead.

Consequently you will note that using \'o in the document directly will produce "ó", but writing ó doesn't cut it. By default Biber converts these macros to their corresponding Unicode characters and sends those to the .bbl file. So effectively we are requesting ó and not \'o in the document even though you wrote \'o in the .bib file.

You can make Biber output the combining macros instead of the Unicode characters by compiling with the --output-safechars command line option.


I would, however, advocate a different approach. If you load fontspec

\usepackage{fontspec}

the default font is set to Latin Modern which contains lots of accented characters natively. So we can just go on using ó in the document and it will appear in the final PDF.

MWE

\documentclass{article}
\usepackage{fontspec}
\usepackage[
backend=biber,
style=alphabetic,
citestyle=authoryear 
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{Beck_Johnson_2013,
  title         ={The Effect of Temperature on \textit{{Anopheles}} Mosquito Population},
  author        ={Bj{\'o}rnstad, Ottar N.},
  year          ={2013},
  journaltitle  ={PLOS ONE}
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\begin{document}
\cite{Beck_Johnson_2013}

\printbibliography
\end{document}

example output

  • If you are using XeLaTeX you may of course use direct Unicode input of accented characters: author = {Bjórnstad, Ottar N.},. – moewe Dec 2 '15 at 7:40
  • I'd like to note that this solution works for \', but not for \v, near as I can tell. – Simon C Apr 9 '16 at 14:31
  • @SimonC I still get the correct output if I use author ={{\v{C}}j{\'o}rnstad, Ottar N.}, in the MWE above. You font will have to contain the requested characters though. – moewe Apr 9 '16 at 14:48
  • 1
    @SimonC That is OK then, the answer quite clearly states that you will either have to load fontspec or use Biber with the --output-safechars. The whole point was that XeLaTeX on its own doesn't cut it. – moewe Apr 9 '16 at 14:53
  • 1
    @SimonC In my tests, a document with newtxtext couldn't display a Č if it was directly input as a UTF-8 character, only the composite \v{C} worked. That makes me think the font doesn't have the characters available natively and needs to use the composite version. You can get that from BIber with --output-safechars. – moewe Apr 9 '16 at 15:01

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.