2

Entering Cyrillic letters into the \ce{} command results in the error:

Package mhchem Error: Assertion failed: Unexpected input character.

This error is solved by putting the Cyrillic text in the \text{} command. However, if I write

$$
\ce{A + B -> Продукты}
$$

in the Chemistry StackExchange forum, this gives the result I want (without producing the error):

enter image description here

So, my question is, why does it work in MathJax and doesn't work on my desktop or overleaf? Is there a way I could change the config of mhchem or do something else to make it work on desktop?

Here's the full code, if needed.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}

\usepackage[version=4]{mhchem}

\author{Azamat}
\date{January, 2023}
\title{Cyrillic letters do not work in \texttt{mhchem}}

\begin{document}

\maketitle

\begin{equation*}
    \ce{A + B -> Products}
\end{equation*}

\begin{equation*}
    \ce{A + B -> Продукты}
\end{equation*}

\end{document}

And the desired output is:

enter image description here

1
  • MathJax is not TeX, although they share (much of) the syntax.
    – egreg
    Commented Jan 22, 2023 at 21:54

1 Answer 1

4

MathJax is not LaTeX.

The mhchem package only “knows” some characters it expects to find in chemistry formulas. Even with XeLaTeX or LuaLaTeX (and suitable fonts supporting Cyrillic), the code breaks with

! Package mhchem Error: Assertion failed: Unexpected input character. In case
(mhchem)                you think this is a bug, please contact the package
(mhchem)                author.

Use \text (which should work also in MathJax).

On the other hand, chemformula with XeLaTeX or LuaLaTeX supports Cyrillic inside \ch (but babel defines \ch for the hyperbolic cosine).

\documentclass{article}
%\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[ukrainian]{babel}

\usepackage{chemformula}

\NewCommandCopy{\CH}{\ch}
\let\ch\relax

\author{Azamat}
\date{January, 2023}
\title{Cyrillic letters do not work in \texttt{mhchem}}

\begin{document}

\maketitle

\CH{A + B -> Products}

\CH{A + B -> Продукты}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .