I want to use two packages chemmacros
and polyglossia
together in my document, and for some reason I don't want to use mhchem
and babel
etc. instead of them. Here are some simplified examples.
Everything behaves fine when setting the language to english
.
\documentclass{article}
\usepackage{polyglossia}
\usepackage{chemmacros}
\setotherlanguage{english} % Produces correct results under language `english'.
\begin{document}
\ch{H2O}
\end{document}
However, when I switch the language to russian
, \ch{H2O}
seems to produce unexpected results, resembling \operatorname{ch}H2O
.
\documentclass{article}
\usepackage{polyglossia}
\usepackage{chemmacros}
\setotherlanguage{russian} % Produces incorrect results under language `russian'.
\begin{document}
\ch{H2O} % An error `Missing $ inserted.' is reported, and the result is incorrect.
$\ch{H2O}$ % No error is reported, but the result is still incorrect.
$\operatorname{ch}H2O$ % As a comparison.
\end{document}
How can I solve this problem and make chemmacros
behave correctly when the document language is russian
?
I am using XeLaTeX as the compiler and TeX Live version 2023.
\setotherlanguage[mathfunctions=false]{russian}
, then russian will no longer overwrite \ch.babel
, feel free to ask for help.polyglossia
very carefully.babel
, butpolyglossia
seems to provide better support for non-Latin scripts, which I use a lot.babel
provides support, with several levels of coverage, for about 300 languages, including RTL scripts, CJK, Indic languages... See the full list in the manual.