unicode-math
我正在尝试将和软件包halloweenmath
一起使用,我发现另一个回应给出一个示例来展示两个包如何协同工作:
\documentclass{article}
\usepackage{xcolor}
\usepackage[nosumlimits]{amsmath}
\usepackage{halloweenmath}
\usepackage{unicode-math}
\setmathfont{Asana Math}[Colour=brown]
\setmathfont{NotoSansMath-Regular.ttf}[Colour=blue,range=it/{latin,greek}]
\setmathfont{NotoSansMath-Regular.ttf}[Colour=blue,range=up/{num}]
\setmainfont{Arial}[Scale=1.1,Colour=red]
\begin{document}
xyz
\[x=f(y)_\alpha\beta,\gamma =\pumpkin(A)^{\mathghost}\] This is a test.
\[\xrightflutteringbat[sin^{2}\theta]{sin\theta}\]
\[ \overscriptrightbroom {a^{2}+b^{2}=c^{3}}\mathwitch* (\phi \minus\phi_{2}) \]
\[ \mathcloud\greatpumpkin_{y=0}^{e^{i}} f(y_x) \]
\end{document}
但是,当我编译此示例时,提供的符号halloweenmath
被“吹出来”了:
但是,当我删除 unicode-math 包时:
\documentclass{article}
\usepackage{xcolor}
\usepackage[nosumlimits]{amsmath}
\usepackage{halloweenmath}
% \usepackage{unicode-math}
% \setmathfont{Asana Math}[Colour=brown]
% \setmathfont{NotoSansMath-Regular.ttf}[Colour=blue,range=it/{latin,greek}]
% \setmathfont{NotoSansMath-Regular.ttf}[Colour=blue,range=up/{num}]
% \setmainfont{Arial}[Scale=1.1,Colour=red]
\begin{document}
xyz
\[x=f(y)_\alpha\beta,\gamma =\pumpkin(A)^{\mathghost}\] This is a test.
\[\xrightflutteringbat[sin^{2}\theta]{sin\theta}\]
\[ \overscriptrightbroom {a^{2}+b^{2}=c^{3}}\mathwitch* (\phi \minus\phi_{2}) \]
\[ \mathcloud\greatpumpkin_{y=0}^{e^{i}} f(y_x) \]
\end{document}
符号显示正常:
自从做出该答案以来,这些软件包是否已更新为不兼容,或者我的机器上的配置有问题?
答案1
该halloweenmath
包使用了\fontdimen
与 LuaLaTeX 不相符的参数unicode-math
。但可以对其进行修补。
\documentclass{article}
\usepackage{xcolor}
\usepackage[nosumlimits]{amsmath}
\usepackage{unicode-math}
\usepackage{halloweenmath}
\usepackage{xpatch}
\usepackage{iftex}
\setmathfont{Asana Math}[Colour=brown]
\setmathfont{NotoSansMath-Regular.ttf}[Colour=blue,range=it/{latin,greek}]
\setmathfont{NotoSansMath-Regular.ttf}[Colour=blue,range=up/{num}]
\setmainfont{Arial}[Scale=1.1,Colour=red]
\ifluatex
\makeatletter
\renewcommand*\@HwM@thickness@units@for[1]{%
\expandafter\Umathfractiondenomvgap\expanded{\style@from@font{#1}}%
}
\def\style@from@font#1{%
\ifx#1\textfont\textstyle\else
\ifx#1\scriptfont\scriptstyle\else
\scriptscriptstyle\fi\fi
}
\xpatchcmd{\@HwM@math@picture}
{\fontdimen 22 #4\tw@}
{\expandafter\Umathaxis\expanded{\style@from@font{#4}}}
{}{}
\xpatchcmd{\@HwM@stylefont@arrowfill}
{\fontdimen 6 #4\tw@}
{\expandafter\Umathquad\expanded{\style@from@font{#4}}}
{}{}
\xpatchcmd{\@HwM@init@swish@dimens}
{\fontdimen 22 #1\tw@}
{\expandafter\Umathaxis\expanded{\style@from@font{#1}}}
{}{}
\makeatother
\fi
\begin{document}
xyz
\[x=f(y)_\alpha\beta,\gamma =\pumpkin(A)^{\mathghost}\] This is a test.
\[\xrightflutteringbat[\sin^{2}\theta]{\sin\theta}\]
\[ \overscriptrightbroom {a^{2}+b^{2}=c^{3}}\mathwitch* (\phi \minus\phi_{2}) \]
\[ \mathcloud\greatpumpkin_{y=0}^{e^{i}} f(y_x) \]
\end{document}
这在 LuaLaTeX 中按预期运行。XeLaTeX 的某些方面不太精确,导致某些字体尺寸计算错误。
使用 LuaLaTeX 输出
使用 XeLaTeX 输出
可以看出鬼是不一样的。