如何在 LuaTeX 中通过 unicode-math 同时使用 Computer Modern 和 Latin Modern 的 Calligraphic \mathcal

如何在 LuaTeX 中通过 unicode-math 同时使用 Computer Modern 和 Latin Modern 的 Calligraphic \mathcal

这是我的 MWE:

计算机现代与拉丁现代的 mathbb 和 mathcal

% !TEX program = lualatex

% DOCUMENT CLASS
\documentclass[11pt,preview,varwidth,%
border={5pt 5pt 5pt 5pt}% left bottom right top
]{standalone}

% PACKAGES
\usepackage{mathtools, amssymb} % Math packages

\let\oldmathbb\mathbb % Computer Modern blackboard bold
\let\oldmathcal\mathcal % Computer Modern calligraphic
\AtBeginDocument{\def\mathbb{\oldmathbb}} % Redefine \mathbb to use Computer Modern
\AtBeginDocument{\def\mathcal{\oldmathcal}} % Redefine \mathcal to use Computer Modern

\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newmathbb\mathbb % Latin Modern blackboard bold
\let\newmathcal\mathcal % Latin Modern calligraphic

\newcommand{\AtoZ}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

% START OF DOCUMENT
\begin{document}
    Computer Modern's \verb|\mathbb|: \(\mathbb{\AtoZ}\)
    
    Latin Modern's \verb|\mathbb|: \(\newmathbb{\AtoZ}\)
    
    Computer Modern's \verb|\mathcal|: \(\mathcal{\AtoZ}\)
    
    Latin  Modern's \verb|\mathcal|: \(\newmathcal{\AtoZ}\)
\end{document}
% END OF DOCUMENT

我主要尝试在包中使用 Computer Modern 的黑板粗体()\mathbb和书法(\mathcal)字体,仅仅是因为我更喜欢它们而不是 Latin Modern 的字体(在那些特定情况下),但我仍然希望能够访问 Latin Modern 的黑板粗体和书法字体,因此需要和宏。LuaTeXunicode-math\newmathbb\newmathcal

从我的 MWE 来看,由于某种原因,我似乎在访问 Computer Modern 的书法字体时遇到了问题。

我读了这个 TeX.SX 答案但是当我使用时\setmathfont[range={cal}]{cmsy10},我最终无法访问拉丁现代的书法字体,因为它似乎将每个书法字体全局更改为cmsy10

尝试解决方案 #1

% !TEX program = lualatex

% DOCUMENT CLASS
\documentclass[11pt,preview,varwidth,%
border={5pt 5pt 20pt 5pt}% left bottom right top
]{standalone}

% PACKAGES
\usepackage{mathtools, amssymb} % Math packages

\let\oldmathbb\mathbb % Computer Modern blackboard bold
\AtBeginDocument{\def\mathbb{\oldmathbb}} % Redefine \mathbb to use Computer Modern

\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newmathbb\mathbb % Latin Modern blackboard bold
\let\newmathcal\mathcal % Latin Modern calligraphic
\setmathfont[range={cal}]{cmsy10} % Computer Modern calligraphic

\newcommand{\AtoZ}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

% START OF DOCUMENT
\begin{document}
    Computer Modern's \verb|\mathbb|: \(\mathbb{\AtoZ}\)
    
    Latin Modern's \verb|\mathbb|: \(\newmathbb{\AtoZ}\)
    
    Computer Modern's \verb|\mathcal|: \(\mathcal{\AtoZ}\)
    
    Latin  Modern's \verb|\mathcal|: \(\newmathcal{\AtoZ}\)
\end{document}
% END OF DOCUMENT

(我收到警告Package fontspec Warning: Font "cmsy10" does not contain requested Script "Math".Package fontspec Warning: OpenType feature 'Style=MathScript' (ssty) not available for font 'cmsy10' with script '' and language 'Default'.Package fontspec Warning: OpenType feature 'Style=MathScriptScript' (ssty) not available for font 'cmsy10' with script '' and language 'Default'.

我也读过另一个 TeX.SX 答案但是当我尝试它的方法时,我仍然无法同时使用 Computer Modern 和 Latin Modern 的书法字体:

尝试解决方案 #2

% !TEX program = lualatex

% DOCUMENT CLASS
\documentclass[11pt,preview,varwidth,%
border={5pt 5pt 20pt 5pt}% left bottom right top
]{standalone}

% PACKAGES
\usepackage{mathtools, amssymb} % Math packages

\let\oldmathbb\mathbb % Computer Modern blackboard bold
\AtBeginDocument{\def\mathbb{\oldmathbb}} % Redefine \mathcal to use Computer Modern

\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math} % Math fonts
\setmathfont{Latin Modern Math}
\let\newmathbb\mathbb % Latin Modern blackboard bold

\ExplSyntaxOn
\makeatletter
\cs_new:Npn\definemathgroup#1#2#3#4{
  \fontspec_set_family:Nnn\l_my_math_font_family{SmallCapsFont={},ItalicFont={},BoldFont={},Script=Math,#3}{#4}
  \exp_args:Nc\new@mathgroup{\string#1}
  \::c\::n\::f\:::\new@symbolfont{\string#1}{TU}{\l_my_math_font_family}{\seriesdefault}{\shapedefault}
  \cs_new:Npn#1##1{#2{\fam\use:c{\string#1}##1}}
}
\makeatother
\ExplSyntaxOff

\definemathgroup{\oldmathcal}{\symcal}{}{cmsy10} % Computer Modern calligraphic
\AtBeginDocument{\def\mathcal{\oldmathcal}} % Redefine \mathcal to use Computer Modern

\definemathgroup{\newmathcal}{\symcal}{}{Latin Modern Math} % Latin Modern calligraphic

\newcommand{\AtoZ}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}

% START OF DOCUMENT
\begin{document}
    Computer Modern's \verb|\mathbb|: \(\mathbb{\AtoZ}\)
    
    Latin Modern's \verb|\mathbb|: \(\newmathbb{\AtoZ}\)
    
    Computer Modern's \verb|\mathcal|: \(\mathcal{\AtoZ}\)
    
    Latin  Modern's \verb|\mathcal|: \(\newmathcal{\AtoZ}\)
\end{document}
% END OF DOCUMENT

(我也收到了警告Package fontspec Warning: Font "cmsy10" does not contain requested Script "Math".

出了什么问题?如何解决这个问题?

谢谢。

答案1

您的问题不太清楚,但这显示了拉丁现代数学 OpenType Blackboard 粗体和书法以及类型 1 AMS Blackboard 粗体和计算机现代书法。 在此处输入图片描述

\documentclass{article}

\usepackage{unicode-math}
\setmathfont{LatinModern Math}
\DeclareMathAlphabet\amsmathbb{U}{msb}{m}{n}
\DeclareMathAlphabet\cmmathcal{OMS}{cmsy}{m}{n}

\begin{document}

$ABC \symbb{ABC} \amsmathbb{ABC}$

$ABC \symcal{ABC} \cmmathcal{ABC}$


$\bar{\cmmathcal{A}} +
 \dot{\cmmathcal{A}}$

$\bar{{\mkern-1.5mu}\cmmathcal{A}{\mkern1.5mu}} + 
 \dot{{\mkern-1.5mu}\cmmathcal{A}{\mkern1.5mu}}$

\end{document}

相关内容