[Tex/LaTex] What packages will let me use Cyrillic characters in math mode

cyrillicmath-modesymbols

Note I'm not actually planning on writing any, for instance, Russian prose or even any Russian words. It's just that, on paper, I've always had the habit of denoting sets by uppercase roman letters, sets of sets by script letters and, when the need arises, sets of sets of sets by uppercase Cyrillic letters. Is there some package I can load which will allow me to typeset (in LaTeX math mode) Cyrillic letters much as I would typeset Greek letters? ie. $\Zhe$ to produce an uppercase zhe. Thanks!

Best Answer

If you use only a few cyrillic letters and only in text size, the simplest way is to say

\usepackage[T2A,T1]{fontenc}
\newcommand{\Zhe}{\mbox{\usefont{T2A}{\rmdefault}{m}{n}\CYRZH}}

If you need them also in subscripts or superscripts, it's possible to use \mathchoice for getting them:

\usepackage[T2A,T1]{fontenc}
\makeatletter
\def\easycyrsymbol#1{\mathord{\mathchoice
  {\mbox{\fontsize\tf@size\z@\usefont{T2A}{\rmdefault}{m}{n}#1}}
  {\mbox{\fontsize\tf@size\z@\usefont{T2A}{\rmdefault}{m}{n}#1}}
  {\mbox{\fontsize\sf@size\z@\usefont{T2A}{\rmdefault}{m}{n}#1}}
  {\mbox{\fontsize\ssf@size\z@\usefont{T2A}{\rmdefault}{m}{n}#1}}
}}
\makeatother
\newcommand{\Ze}{\easycyrsymbol{\CYRZ}}

This makes available \Ze at all sizes.

The names to use are easy: just add \cyr or \CYR in front of the letter's English transliteration. For instance, the lowercase "shcha" is \cyrshch, the uppercase is \CYRSHCH. This is called the character's LICR (LaTeX internal character representation).

Another solution, useful if you need the entire repertory without wasting too much resources is to say

\usepackage[T2A,T1]{fontenc}
\DeclareSymbolFont{cyrillic}{T2A}{cmr}{m}{n}
\DeclareMathSymbol{\Sha}{\mathalpha}{cyrillic}{216}

since the Sha has that position in the T2A encoding; this can be deduced from the definitions in the file t2aenc.def. By using some sorcery, we can directly use the LICR name of the characters:

\usepackage[T2A,T1]{fontenc}
\DeclareSymbolFont{cyrillic}{T2A}{cmr}{m}{n}
\def\makecyrsymbol#1#2{%
  \begingroup\edef\temp{\endgroup
    \noexpand\DeclareMathSymbol{\noexpand#1}
    {\noexpand\mathalpha}{cyrillic}%
    {\expandafter\expandafter\expandafter
     \calccyr\expandafter\meaning\csname T2A\string#2\endcsname\end}}%
  \temp}
\expandafter\def\expandafter\calccyr\string\char#1\end{#1}

\makecyrsymbol\Zhe\CYRZH

The command \makecyrsymbol has two arguments: the first one is the desired name for the symbol, the second one is the internal LaTeX name for the cyrillic letter. With that last line we have defined \Zhe as a math command in all sizes.

The \usepackage[T2A,T1]{fontenc} line is necessary for resetting the document's main encoding to T1; use OT1, instead of T1 if you don't need accented letters because your language is English. I have prefixed with that line each of the four solutions: pick your preferred one.

Related Question