2

I am using the Stix 2 fonts for some of my documents and am pretty happy with them except for one thing: I feel they place an excessive amount of vertical spacing around fraction lines in text style math. Here's a comparison to 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}

MWE output

This leads to fractions being pretty much unusable in in-line math, which one might argue is a good thing (though I do not agree). But even in display math I find them taking up an unreasonable amount of space when appearing in nested fractions of in exponents. Note how the "middle" H in the nested fraction is closer to the big fraction line than to the small one. This just looks weird.

So my question is twofold:

  • Is this really intended? What might be the reasons for making it so?
  • Do I have any recourse for changing this without changing fonts? That is, is there some (La)TeX dimension I can adjust to reduce this space?
schtandard
  • 14,892

2 Answers2

1

As in classic tex you can fiddle with the parameters, here I reduce the spacing and increase the rule width (it's subtle, but you may notice the difference)

enter image description here

% !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}

David Carlisle
  • 757,742
0

For anyone looking to do the same: Here are the settings I settled on following David's answer.

% !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}

MWE output

schtandard
  • 14,892