# Non-ASCII characters in Biblatex

I am using biblatex with backend=biber and the following .bib file:

@article{concellon_synthesis_2006,
title = {Synthesis of Enantiopure ({αS,βS)-} or ({αR,βS)-β-Amino} Alcohols by Complete Regioselective Opening of Aminoepoxides by Organolithium Reagents {LiAlH4} or {LiAlD4}},
volume = {71},
number = {17},
journal = {J. Org. Chem.},
author = {Concellón, José M. and Bernad, Pablo L. and del Solar, Virginia and Suárez, José Ramón and García-Granda, Santiago and Díaz, M. Rosario},
month = aug,
year = {2006},
pages = {6420--6426},
}


I can successfully compile this with biber, but then the pdflatex command fails due to the α and β in the .bbl file. I am astonished by the fact that there seems to be no elegant solution for this problem even though this appears to be an everyday scenario, in scientific literature at least.

What options do I have to fix this problem?

-

You have to assign a meaning to the Unicode characters you're using and that aren't set by default. Here's a way.

\begin{filecontents*}{\jobname.bib}
@article{concellon_synthesis_2006,
title = {Synthesis of Enantiopure ({αS,βS)-} or ({αR,βS)-β-Amino} Alcohols by Complete Regioselective Opening of Aminoepoxides by Organolithium Reagents {LiAlH4} or {LiAlD4}},
volume = {71},
number = {17},
journal = {J. Org. Chem.},
author = {Concellón, José M. and Bernad, Pablo L. and del Solar, Virginia and Suárez, José Ramón and García-Granda, Santiago and Díaz, M. Rosario},
month = aug,
year = {2006},
pages = {6420--6426},
}
\end{filecontents*}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{newunicodechar}
\newunicodechar{α}{\ensuremath{\alpha}}
\newunicodechar{β}{\ensuremath{\beta}}

\usepackage{biblatex}
\begin{document}
\cite{concellon_synthesis_2006}
\printbibliography
\end{document}


The usage of filecontents is just for getting a self-contained MWE.

A different solution is to use the \textgreek package, which also spares from newunicodechar because it defines the meaning of the Unicode Greek letters to be equivalent to their \text... counterpart. So α becomes \textalpha.

\begin{filecontents*}{\jobname.bib}
@article{concellon_synthesis_2006,
title = {Synthesis of Enantiopure ({αS,βS)-} or ({αR,βS)-β-Amino} Alcohols by Complete Regioselective Opening of Aminoepoxides by Organolithium Reagents {LiAlH4} or {LiAlD4}},
volume = {71},
number = {17},
journal = {J. Org. Chem.},
author = {Concellón, José M. and Bernad, Pablo L. and del Solar, Virginia and Suárez, José Ramón and García-Granda, Santiago and Díaz, M. Rosario},
month = aug,
year = {2006},
pages = {6420--6426},
}
\end{filecontents*}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{textgreek}

\usepackage{biblatex}
\begin{document}
\cite{concellon_synthesis_2006}
\printbibliography
\end{document}


The result is

-
I get the following error when running pdflatex, biber and pdflatex on your file: ! Package inputenc Error: Unicode char \u8:α not set up for use with LaTeX. – gncs Apr 7 '13 at 11:11
The second solution should be preferred as far as IUPAC is concerned: they recommend to use upright greek letters (and of course \ce{LiALH4} with mhchem, but that's another topic...) – clemens Apr 7 '13 at 11:11

biber is designed to be able to recode into TeX macros automatically in exactly this situation. This is explained in the biber manual - the problem you face is a limitation of inputenc and PDFLaTeX which doesn't understand all of UTF-8. Load biblatex with the safeinputenc option and then call biber with the --output_safecharsset=full option. This will do it all automatically for you.

To switch to the textgreek variants, it's quite easy, you have to have a custom UTF-8<->TeX macro XML conversion data file (biber comes with a default which is fine for most use). To use the textgreek variants, get this file:

https://www.dropbox.com/s/ln3ht1xd9mmgu9w/recode.xml

Then call biber like this:

biber --recodedata=<path to file downloaded above>


Then just make sure you have \usepackage{textgreek} in your LaTeX document and you are using the safeinputenc option to biblatex.

A much easier way of dealing with this is just switching to LuaLaTeX since biber deals with UTF-8 without problems. Then there is no need for special biber option or the safeintputenc biblatex option.

-
Thank you for this very elegant solution, however, @cgnieder mentioned the IUPAC and with your solution the α is an $\alpha$ and not a \textalpha in the .bbl file. Do you have solution for that? – gncs Apr 7 '13 at 11:25
Updated answer for using textgreek variants. – PLK Apr 7 '13 at 13:41

Thanks to PLK and cgnieder I managed to find a solution that I am happy with. It is based on PLK's answer but also ensures that the Greek letters are upright.

\begin{filecontents*}{\jobname.bib}
@article{concellon_synthesis_2006,
title = {Synthesis of Enantiopure ({αS,βS)-} or ({αR,βS)-β-Amino} Alcohols by Complete Regioselective Opening of Aminoepoxides by Organolithium Reagents {LiAlH4} or {LiAlD4}},
volume = {71},
number = {17},
journal = {J. Org. Chem.},
author = {Concellón, José M. and Bernad, Pablo L. and del Solar, Virginia and Suárez, José Ramón and García-Granda, Santiago and Díaz, M. Rosario},
month = aug,
year = {2006},
pages = {6420--6426},
}
\end{filecontents*}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textgreek}

\usepackage[backend=biber, safeinputenc]{biblatex}
\begin{document}
\cite{concellon_synthesis_2006}
\printbibliography
\end{document}


Now, the macro file (found on Biber CTAN /biblatex-biber-1.5/lib/Biber/LaTeX/recode_data.xml) has to be edited. This:

<maps type="greek" set="full">
<map><from>alpha</from>      <to hex="3B1">α</to></map>
<map><from>beta</from>       <to hex="3B2">β</to></map>
...
<map><from>Omega</from>      <to hex="3A9">Ω</to></map>
</maps>


Has to be changed to this:

  <maps type="wordmacros" set="base,full">
<map><from>textalpha</from>      <to hex="3B1">α</to></map>
<map><from>textbeta</from>       <to hex="3B2">β</to></map>
...
<map><from>textOmega</from>      <to hex="3A9">Ω</to></map>
</maps>


and saved in your working directory. The package textgreek provides the \textalpha command which results in an upright α.

Run Biber with the following options:

--recodedata=recode_data.xml


And the following pdflatex run should produce a bibliography with upright Greek letters.

-
If you want to follow IUPAC to the letter: they recommend to set Cahn-Ingold-Prelog descriptors like S and R with an italic font series – clemens Apr 7 '13 at 14:03
If you are making a custom recode XML (as you are), you can decide which recode "set" the mappings go into so you can set set="base,full" and then you don't need the --output_safecharsset=full option since "base" is the default for biber. – PLK Apr 7 '13 at 14:28

If using Unicode is what you want, you should consider using fontspec together with a Unicode font with Greek letters (which virtually all Unicode fonts have). Here I have used Linux Libertine.

\documentclass{article}
\usepackage{filecontents,fontspec,biblatex}
\setmainfont[Ligatures=TeX]{Linux Libertine O}

\begin{filecontents}{\jobname.bib}
@article{concellon_synthesis_2006,
title = {Synthesis of Enantiopure ({αS,βS)-} or ({αR,βS)-β-Amino} Alcohols by Complete Regioselective Opening of Aminoepoxides by Organolithium Reagents {LiAlH4} or {LiAlD4}},
volume = {71},
number = {17},
journal = {J. Org. Chem.},
author = {Concellón, José M. and Bernad, Pablo L. and del Solar, Virginia and Suárez, José Ramón and García-Granda, Santiago and Díaz, M. Rosario},
month = aug,
year = {2006},
pages = {6420--6426}}
\end{filecontents}