
私は xelatex を使用していますが、数式でキリル文字を通常の文字と同じように使用したいと考えています。次のコードでは、結果の PDF の数式にキリル文字の代わりに空白が表示されます。
\documentclass{letter}
\usepackage{fontspec}
\setmainfont{Liberation Serif}
\setmathrm{Liberation Serif}
\begin{document}
Cyrillics: {абВ 0123456789} \it{абВ 0123456789}
$ abC = 1,234567890 = абВ = \sin {1,234567890 {абВ}_{абВ} } \Phi \alpha $
\end{document}
ログファイルにはこう書いてある
Missing character: There is no а in font cmmi10!
Missing character: There is no б in font cmmi10!
Missing character: There is no В in font cmmi10!
Missing character: There is no а in font cmmi7!
Missing character: There is no б in font cmmi7!
Missing character: There is no В in font cmmi7!
すべてのキリル文字スニペットに \mathit などを使用するのは、ある意味では半分の解決策です。
構成内の「Latin Modern」ファミリーを、キリル文字と適切なグリフの両方をカバーする「CMU」(「Computer Modern Unicode」) ファミリーなどに置き換えることは可能ですか? (「unicode-math」パッケージでこの問題を解決しようとしたところ、同様の問題が発生しました)。
答え1
hyperref
およびがない場合polyglossia
(および との間で、私がフォローしていない何らかのやり取りが発生する場合)、次のようになります。
ムウェ
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{unicode-math}
%\usepackage{polyglossia}
%\setdefaultlanguage{russian}
%\setotherlanguage{english}
%\newcommand\cyrillicfont{Noto Serif}
\setmainfont{Liberation Serif}
\setmathrm{Liberation Serif}
%\usepackage[russian]{hyperref}
\setmathfont{XITS Math}
%See: https://tex.stackexchange.com/questions/201239/cant-get-unicode-symbols-in-math-mode
\DeclareSymbolFont{cyrletters}{\encodingdefault}{\familydefault}{m}{it}
\newcommand{\makecyrmathletter}[1]{%
\begingroup\lccode`a=#1\lowercase{\endgroup
\Umathcode`a}="0 \csname symcyrletters\endcsname\space #1
}
\count255="409
\loop\ifnum\count255<"44F
\advance\count255 by 1
\makecyrmathletter{\count255}
\repeat
\begin{document}
\[
(д+ф)^{2}=д^{2}+2дф+ф^{2}м
\]
\[
г л а м н я^{2^{i}}
\]
Inline math mode: $ abC = 1,234 = абВ = \sin ({1,67895 \times {абВ}_{абВ} }) \Phi \alpha $
xxx $а + ц ж + е$ xxx
\end{document}
xelatex (Windows では miktex) でコンパイル:
This is XeTeX, Version 3.14159265-2.6-0.999992 (MiKTeX 2.9.7300 64-bit) entering extended mode (cyrillic_maths_egreg2a.tex LaTeX2e <2020-02-02> patch level 5 L3 programming layer <2020-03-06>
答え2
実際に私の質問にかなり近い答えを出しているのは、@Cicada が提案したグリフの再定義へのアプローチ (コード内の参照) と、「mathfont」パッケージ (CTAN ホームページから 1 クリック) を組み合わせたものです。OpenOffice の TexMaths アドオンでも動作します。
\documentclass{letter}
\usepackage{mathfont}
\setmainfont{Liberation Serif}
\mathfont{Liberation Serif}
% The glyphs redefinition code by https://tex.stackexchange.com/users/182648/cicada
% as posted at https://tex.stackexchange.com/a/534590/210048
% See also: https://tex.stackexchange.com/questions/201239/cant-get-unicode-symbols-in-math-mode
\DeclareSymbolFont{cyrletters}{\encodingdefault}{\familydefault}{m}{it}
\newcommand{\makecyrmathletter}[1]{%
\begingroup\lccode`a=#1\lowercase{\endgroup
\Umathcode`a}="0 \csname symcyrletters\endcsname\space #1
}
\count255="409
\loop\ifnum\count255<"44F
\advance\count255 by 1
\makecyrmathletter{\count255}
\repeat
\begin{document}
Text: {\it{abC}} = 1,234567890 = {\it{абВ}\footnotesize{абВ}} = {sin} 1,234567890 \, {Φ} {\it{α}}
Math: $ abC = 1,234567890 = {абВ}_{абВ} = \sin {1,234567890} \, \Phi \, \alpha $
\end{document}
更新: さらに良いのは、「mathspec」パッケージを使用することです。これは、「mathfont」と同様に、「amsmath」と競合しません。同じサンプルコードで、
\usepackage{mathfont}
\setmainfont{Liberation Serif}
\mathfont{Liberation Serif}
と
\usepackage{amsmath}
\usepackage{mathspec}
\setmainfont{Liberation Serif}
\setallmainfonts{Liberation Serif}