# I can't get non-Latin characters to display using Babel

UPDATE: After writing up this post I did some last-minute testing that seems to undermine my Minimum Working Example.

If I remove (comment out) the \usepackage{Alegreya} line in my MWE, everything works fine.

However, in my real-world document, that didn't solve the problem. That document has lots of other packages loaded, and when I removed them one-by-one to narrow it down for the MWE, that pointed me only to the \usepackage{Alegreya} line. (Dropping that line didn't affect the body font, which is set by the \setmainfont{Alegreya} command.

So I guess I need more guidance how how to troubleshoot this, and what I might be doing wrong. Below is my query as originally written and the code for me MWE. Thanks.

My English-language document has a few instances calling for non-Latin characters: Greek, Chinese, Hebrew.

(Hebrew has right-to-left flow, so for now I'm just working on the two others.)

My MWE is adapted from the example on p.8 of the Babel package documentation (babel.pdf), section 1.3 Mostly monolingual documents.

\documentclass[letterpaper,10pt,index=toc]{scrbook} % {book} class doesn't change result

\usepackage{microtype}
\usepackage{fontspec}
\usepackage{Alegreya}  % Greek, Chinese characters display if this is commented out
\setmainfont{Alegreya}
\setmainfont{Alegreya}
\usepackage{babel}

\babelfont[russian]{rm}{FreeSerif}
\babelfont[greek]{rm}{FreeSerif}
\babelfont[chinese]{rm}{NotoSerif}  % sc' at end refers to simplified Chinese

\begin{document}

Main font Alegreya

\foreignlanguage{russian}{Русский},

\foreignlanguage{spanish}{Español},

\foreignlanguage{greek}{𝜇}torrent; as a workaround, Greek letter \emph{mu} can be
\\coded in a different font using math mode: $\mu$torrent,

China Garden \foreignlanguage{chinese}{漢宫}.

\end{document}


Russian and Spanish examples were included from the babel.pdf code as a control.

Compiling with LuaLaTeX, the cyrillic characters and the ñ display fine, but the Greek mu and the Chinese characters do not appear at all. I used several other variations of the font name — Noto Serif, NotoSerif, etc., all with negative results.

• look in the log you should see messages such as Missing character: There is no 𝜇 (U+1D707) in font Alegreya:mode=node;script= latn;language=dflt;+tlig;! If the font doesn't have the character, tex can't display it. Apr 20 at 15:07
• you wouldn't expect to find U+1d707 (the math italic mu) in a text font. Did you intend a normal text mu here? Apr 20 at 15:09
• There is a warning in the manual in this regard: “WARNING Using \setxxxxfont and \babelfont at the same time is discouraged, but very often works as expected. However, be aware with \setxxxxfont the language system will not be set by babel and should be set with fontspec if necessary.” It seems you have run into a case where it doesn't work as expected. Apr 20 at 15:44
• I'll prepare a workaround, but not right now (tomorrow). Apr 20 at 15:54
• Sadly, the package Alegreya selects the font in a non-standard way (it even redefines \rmfamily in a somewhat hackish way), while babel assumes the default mechanism. So, I don't think there is a real solution, except setting the font directly with either \setmainfont or \babelfont. See Davislor's answer. Apr 22 at 12:30

You want to use \babelfont consistently, rather than mixing it with \setmainfont. If you load Alegreya this way, you do not also need \usepackage{alegreya}.

\documentclass[letterpaper,10pt,index=toc]{scrbook} % {book} class doesn't change result
\usepackage[russian, spanish, english]{babel}
\usepackage{fontspec}
\usepackage{microtype}

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }

\babelfont{rm}
[Scale=1.0, Ligatures=Common]{Alegreya} % The default, used for Spanish and English.
\babelfont[russian]{rm}
[Language=Default]{FreeSerif}
\babelprovide[import=el]{greek} % Or import=el-polyton for polytonic Greek.
\babelfont[greek]{rm}
[Language=Default]{FreeSerif}
\babelprovide[import=zh-hans]{chinese} % Simplified Chinese
\babelfont[chinese]{rm}
[Renderer=HarfBuzz]{Noto Serif CJK sc}  % sc' at end refers to simplified Chinese

\begin{document}

Main font Alegreya

\foreignlanguage{russian}{Русский},

\foreignlanguage{spanish}{Español},

\foreignlanguage{greek}{𝜇}torrent; as a workaround, Greek letter \emph{mu} can be
\\coded in a different font using math mode: $\mu$torrent,

China Garden \foreignlanguage{chinese}{漢宫}.

\end{document}


With the onchar=ids fonts option to \babelprovide, you could simply type in Russian, Chinese or Greek and it would work. This cannot distinguish between different languages that use the same script, such as Spanish and English. This feature, as well as microtype font expansion, only work in recent versions of LuaLaTeX.

\documentclass[letterpaper,10pt,index=toc]{scrbook} % {book} class doesn't change result
\usepackage[spanish, english]{babel}
\usepackage{fontspec}
\usepackage{microtype}
\usepackage{newunicodechar}

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }

\babelfont{rm}
[Scale=1.0, Ligatures=Common]{Alegreya} % The default, used for Spanish and English.
\babelprovide[import=ru, onchar=ids fonts]{russian}
\babelfont[russian]{rm}
[Language=Default]{FreeSerif}
\babelprovide[import=el, onchar=ids fonts]{greek} % Or import=el-polyton for polytonic Greek.
\babelfont[greek]{rm}
[Language=Default]{FreeSerif}
\babelprovide[import=zh-hans, onchar=ids fonts]{chinese} % Simplified Chinese
\babelfont[chinese]{rm}
[Renderer=HarfBuzz]{Noto Serif CJK sc}  % sc' at end refers to simplified Chinese

%% Babel does not consider the mathematical alphanumeric symbol 𝜇 to be a Greek letter,
%% Therefore, set it active and define it either as italic text or as math.
\newunicodechar{𝜇}{\textit{μ}}

\begin{document}

Main font Alegreya

Русский,

\foreignlanguage{spanish}{Español},

𝜇torrent; as a workaround, Greek letter \emph{mu} can be
\\coded in a different font using math mode: $\mu$torrent,

China Garden 漢宫.

\end{document}


This is only one of several possible ways to handle the mathematical alphanumeric Unicode character. If you wanted to use them in math mode as well, you might prefer \ensuremath{\mu}`.

There are a few different ways to make the Greek math letters match the text font as well.