![数学内联无衬线字体](https://linux22.com/image/407897/%E6%95%B0%E5%AD%A6%E5%86%85%E8%81%94%E6%97%A0%E8%A1%AC%E7%BA%BF%E5%AD%97%E4%BD%93.png)
我用过这个回答使我的文档中的所有数学运算都遵循 Sans-Serif 字体。
但是,每当我使用 Polyglossia 包并添加另一种语言时,都会收到一条错误消息:
Package Polyglossia error: The current Latin font Arial(1) does not contain the "Cyrillic" script! Please define \cyrillicfont with \newfontfamily command.
尽管我定义了西里尔字体(使用此回答)。
可以使用以下方法产生错误希腊语,希伯来语和阿拉伯也一样。
%:Preamble
%:Class
\documentclass[]{article}
%:Language
\usepackage{polyglossia}
%Commenting out the following lines produces the error:
%\setdefaultlanguage{russian}
%\setotherlanguage{english}
%\setmainfont[Ligatures=TeX]{Arial}
%\newfontfamily\cyrillicfont{Arial}[Script=Cyrillic]
%:Fonts
\usepackage{fontspec}
\renewcommand\familydefault{\sfdefault}
%:Math_Font
% Taken from:https://tex.stackexchange.com/a/41501/179187
\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{cmbr}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{cmbrm}{m}{it}
\SetSymbolFont{symbols}{sans}{OMS}{cmbrs}{m}{n}
\SetMathAlphabet{\mathit}{sans}{OT1}{cmbr}{m}{sl}
\SetMathAlphabet{\mathbf}{sans}{OT1}{cmbr}{bx}{n}
\SetMathAlphabet{\mathtt}{sans}{OT1}{cmtl}{m}{n}
\SetSymbolFont{largesymbols}{sans}{OMX}{iwona}{m}{n}
\DeclareMathVersion{boldsans}
\SetSymbolFont{operators}{boldsans}{OT1}{cmbr}{b}{n}
\SetSymbolFont{letters}{boldsans}{OML}{cmbrm}{b}{it}
\SetSymbolFont{symbols}{boldsans}{OMS}{cmbrs}{b}{n}
\SetMathAlphabet{\mathit}{boldsans}{OT1}{cmbr}{b}{sl}
\SetMathAlphabet{\mathbf}{boldsans}{OT1}{cmbr}{bx}{n}
\SetMathAlphabet{\mathtt}{boldsans}{OT1}{cmtl}{b}{n}
\SetSymbolFont{largesymbols}{boldsans}{OMX}{iwona}{bx}{n}
\DeclareMathVersion{sans}
\SetSymbolFont{operators}{sans}{OT1}{cmsmf}{m}{n}
\SetSymbolFont{letters}{sans}{OML}{cmssm}{m}{it}
\SetSymbolFont{symbols}{sans}{OMS}{cmsssy}{m}{n}
\SetMathAlphabet{\mathit}{sans}{OT1}{cmssm}{m}{sl}
\SetMathAlphabet{\mathbf}{sans}{OT1}{cmsssy}{bx}{n}
\SetMathAlphabet{\mathtt}{sans}{OT1}{cmssex}{m}{n}
\SetSymbolFont{largesymbols}{sans}{OMX}{cmssex}{m}{n}
\newif\IfInSansMode
\let\oldsf\sffamily
\renewcommand*{\sffamily}{\oldsf\mathversion{sans}\InSansModetrue}
\let\oldbf\bfseries
\renewcommand*{\bfseries}{\oldbf\IfInSansMode\mathversion{boldsans}\else\mathversion{bold}\fi\relax}
\let\oldnorm\normalfont
\renewcommand*{\normalfont}{\oldnorm\InSansModefalse\mathversion{normal}}
\let\oldrm\rmfamily
\renewcommand*{\rmfamily}{\oldrm\InSansModefalse\mathversion{normal}}
%:Start
\begin{document}
R
$R$
$\mathsf{R=r}$
\end{document}
答案1
您正在将 \familydefault 重新定义为等于 \sfdefault。这意味着 polyglossia 正在寻找无衬线西里尔字体。您可以使用以下方式进行设置
\newfontfamily\cyrillicfontsf{Arial}[Script=Cyrillic]
\cyrillicfonttt
设置打字机字体可能也是一个好主意。