我正在为一些文档使用 Stix 2 字体,除了一件事之外,我对它们非常满意:我觉得它们在文本样式数学中的分数线周围放置了过多的垂直间距。以下是与 Latin Modern 的比较。
% !TeX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\newfontfamily\lmodern{LatinModernRoman}
\newfontfamily\stixii{StixTwoText}
\setmathfont{LatinModernMath}[version=lmodern]
\setmathfont{STIXTwoMath}[version=stix2]
\NewDocumentEnvironment{comparison}{ O{.48\textwidth} +b }{%
\par
\begin{minipage}{#1}%
\lmodern
\mathversion{lmodern}%
\raggedleft
#2%
\end{minipage}\hfil
\begin{minipage}{#1}%
\stixii
\mathversion{stix2}%
\raggedright
#2%
\end{minipage}%
\par\vskip 1ex\relax
}{}
\begin{document}\centering
\begin{comparison}
Latin Modern vs Stix~2
\end{comparison}
\begin{comparison}
\(\frac HH\)
\end{comparison}
\begin{comparison}
\(\displaystyle
\frac{ \frac HH }{ H + H }
\)
\end{comparison}
\begin{comparison}
\(\displaystyle
H^{\frac HH}
\)
\end{comparison}
\end{document}
这导致分数在内联数学中几乎无法使用,有人可能会认为这是一件好事(尽管我不同意)。但即使在显示数学中,我也发现它们在指数的嵌套分数中出现时占用了不合理的空间。请注意H
嵌套分数中的“中间”距离大分数线比距离小分数线更近。这看起来很奇怪。
所以我的问题有两个:
- 这真的是故意的吗?这样做的原因可能是什么?
- 我有什么办法可以在不更改字体的情况下更改此设置吗?也就是说,我可以调整某些 (La)TeX 尺寸来减少此空间吗?
答案1
就像在经典 tex 中一样,您可以摆弄参数,在这里我减少了间距并增加了规则宽度(这很微妙,但您可能会注意到差异)
% !TeX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\newfontfamily\lmodern{LatinModernRoman}
\newfontfamily\stixii{StixTwoText}
\setmathfont{LatinModernMath}[version=lmodern]
\setmathfont{STIXTwoMath}[version=stix2]
\NewDocumentEnvironment{comparison}{ O{.48\textwidth} +b }{%
\par
\begin{minipage}{#1}%
\lmodern
\mathversion{lmodern}%
\raggedleft
#2%
\end{minipage}\hfil
\begin{minipage}{#1}%
\stixii
\mathversion{stix2}%
\sbox0{$$}% wake up math settings
\z\raggedright
#2%
\end{minipage}%
\par\vskip 1ex\relax
}{}
\def\z{
\Umathfractionnumvgap\displaystyle=0pt
\Umathfractionnumvgap\textstyle=0pt
\Umathfractionnumvgap\scriptstyle=0pt
\Umathfractionnumup\displaystyle=0pt
\Umathfractionnumup\textstyle=0pt
\Umathfractionnumup\scriptstyle=0pt
\Umathfractionrule\displaystyle=25pt
\Umathfractionrule\textstyle=25pt
\Umathfractionrule\scriptstyle=25pt
}
\begin{document}\centering
\begin{comparison}
Latin Modern vs Stix~2
\end{comparison}
\begin{comparison}
\(\frac HH\)
\end{comparison}
\begin{comparison}
\(\displaystyle
\frac{ \frac HH }{ H + H }
\)
\end{comparison}
\begin{comparison}
\(\displaystyle
H^{\frac HH}
\)
\end{comparison}
\end{document}
答案2
对于任何想要做同样事情的人:以下是我按照以下方式确定的设置大卫的回答。
% !TeX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\newfontfamily\lmodern{LatinModernRoman}
\newfontfamily\stixii{StixTwoText}
\setmathfont{LatinModernMath}[version=lmodern]
\setmathfont{STIXTwoMath}[version=stix2]
\NewDocumentEnvironment{comparison}{ O{.48\textwidth} +b }{%
\par
\begin{minipage}{#1}%
\lmodern
\mathversion{lmodern}%
\raggedleft
#2%
\end{minipage}\hfil
\begin{minipage}{#1}%
\stixii
\mathversion{stix2}%
\raggedright
\stixiifontpatch
#2%
\end{minipage}%
\par\vskip 1ex\relax
}{}
\makeatletter
\def\scaleluamathparam#1#2#3{%
\@tempdima=#1#2%
#1#2=#3\@tempdima
}
\makeatother
\def\stixiifontpatch{%
\sbox0{\(\)}% wake up math settings
\scaleluamathparam\Umathfractionnumup\textstyle{.7}%
\scaleluamathparam\Umathfractionnumup\crampedtextstyle{.7}%
\scaleluamathparam\Umathfractionnumup\scriptstyle{.7}%
\scaleluamathparam\Umathfractionnumup\crampedscriptstyle{.7}%
\scaleluamathparam\Umathfractionnumup\scriptscriptstyle{.7}%
\scaleluamathparam\Umathfractionnumup\crampedscriptscriptstyle{.7}%
\scaleluamathparam\Umathfractiondenomdown\textstyle{.7}%
\scaleluamathparam\Umathfractiondenomdown\crampedtextstyle{.7}%
\scaleluamathparam\Umathfractiondenomdown\scriptstyle{.7}%
\scaleluamathparam\Umathfractiondenomdown\crampedscriptstyle{.7}%
\scaleluamathparam\Umathfractiondenomdown\scriptscriptstyle{.7}%
\scaleluamathparam\Umathfractiondenomdown\crampedscriptscriptstyle{.7}%
}
\usepackage{mathtools}
\usepackage{xfrac}
\begin{document}\centering
\begin{comparison}
Latin Modern vs Stix~2
\end{comparison}
\begin{comparison}
\(\displaystyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\crampeddisplaystyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\textstyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\crampedtextstyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\scriptstyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\crampedscriptstyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\scriptscriptstyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\begin{comparison}
\(\crampedscriptscriptstyle\frac HH\frac{H_H^H}{H_H^H}\)
\end{comparison}
\end{document}