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?
3
  • 1
    luatex or xetex? Commented Nov 16, 2021 at 14:18
  • @DavidCarlisle LuaLaTeX. (Though the same thing happens with pdfLaTeX. But for the MWE LuaLaTeX was much more convenient.)
    – schtandard
    Commented Nov 16, 2021 at 14:28
  • 1
    same thing happens but the setting mechanisms are different if you want to change it, I posted a luatex version. Commented Nov 16, 2021 at 14:54

2 Answers 2

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}
1
  • Very subtle indeed. Maybe you should do some work on microtype..
    – schtandard
    Commented Nov 16, 2021 at 14:55
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

4
  • You didn't like my settings? :( Commented Nov 17, 2021 at 14:24
  • @DavidCarlisle I did, but I decided to go for something a bit more in-your-face.
    – schtandard
    Commented Nov 17, 2021 at 15:24
  • as noted in the gh issue you probably want to patch the settings on to \glb@settings so they happen whenever the fonts are reset in \large or \text in a subscript or .. Commented Nov 17, 2021 at 15:29
  • @DavidCarlisle Hmm, I can't quite get that to work. Just saying \appto\glb@settings{\stixiifontpatch} works for simple cases like \large but fails with \sfrac in math mode. I might just do it in Lua..
    – schtandard
    Commented Nov 17, 2021 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .