I use babel
with lualatex
to write documents in our native language Hebrew, and I encountered a strange issue. Despite the fact I defined a custom font for Hebrew only, when I use roman style in math mode, for example, \mathrm{kg}
, it uses the Hebrew font instead of the default English font:
\documentclass[a4paper, 12pt]{extarticle}
\usepackage[bidi=basic, layout=tabular]{babel}
\babelprovide[main, import, alph=letters, Alph=letters]{hebrew}
\babelprovide[import]{english}
\babelfont[hebrew]{rm}{Calibri}
\babelfont[hebrew]{sf}{Calibri}
\begin{document}
\[ kg \qquad \mathrm{kg} \]
\end{document}
The result is:
and I want to use the default English font for math expressions. Commenting out the babel
setup (since this example doesn't involve any Hebrew) gives the desired result:
Notice that regular italic math is unaffected and rendered correctly in both cases.
How can I configure babel
to use the default fonts for English, especially in math mode (I don't want any Hebrew involved in math most of the time)?
Best Answer
This is from section 3.2 of fontspec's manual
When the command
\babelfont
is used,babel
loadsfontspec
, hence the changes in the font.So, as documented, you can either load package for math fonts, or pass the
no-math
option tofontspec
to suppress such changes.Since
fontspec
is loaded implicitly bybabel
, you will have to pass theno-math
option from the\documentclass
deceleration, oror by adding the line\PassOptionsToPackage{no-math}{fontspec}
before the first use of\babelfont
, as you suggested.