Babel uses the wrong font for roman math

babelfontshebrew

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

By default, fontspec adjusts LaTeX’s default maths setup in order to maintain the correct Com- puter Modern symbols when the roman font changes. However, it will attempt to avoid doing this if another maths font package is loaded (such as mathpazo or the unicode-math package). If you find that fontspec is incorrectly changing the maths font when it shouldn’t be, apply the no-math package option to manually suppress its behaviour here.

When the command \babelfont is used, babel loads fontspec, hence the changes in the font.

So, as documented, you can either load package for math fonts, or pass the no-math option to fontspec to suppress such changes.

Since fontspec is loaded implicitly by babel, you will have to pass the no-math option from the \documentclass deceleration, oror by adding the line \PassOptionsToPackage{no-math}{fontspec} before the first use of \babelfont, as you suggested.

Related Question