[luatex] Poor Spacing in the \frac Environment

Ulrik VIeth ulrik.vieth at arcor.de
Mon Jan 19 01:14:27 CET 2015

Good question.

I didn't have time to experiment, what (if anything) is wrong,
but I can try to give some explanations.
(see also https://www.tug.org/TUGboat/tb30-1/tb94vieth.pdf)

In general, there are 2 different mechanisms at play here.

There is one set of font metrics parameters which determines the default 
position of the numerator or denominator relative to the fraction bar, 
which applies as long when symbols aren't too big.
This is what applies to \frac{xxxxxxLLLLLL}{xxxxxxTTTTTT}.

There is another set of parameters which ensures a minimum clearance
above or below the fraction bar, which applies when symbols get bigger, 
e.g. when symbols have superscipts or subscripts attached.
This is what applies to \frac{2(x-1)-(x^{2}-1)}{(x^{2}-1)(x-1)}.

Presumably the parameters for the default positioned are tuned for
lowercase symbols of x-height, not necessarily for capital letters.

In your case the numerators has no descenders below the baseline,
but the denominator has ascenders above x-height, so the gap above
the rule looks big for L, but the gap below looks small for T.

If you had descenders in the numerator, e.g. J or g, or \gamma,
the gap above the rule would be smaller without shifting the position.
Likewise, if you had subscripts such asx_{0} in the numerator,
the gap above the rule would be smaller without shifting the position.

In general, there will always be some cases, where the spacing might
look a little uneven, especially if you have ascenders or descenders.
Just try all combinations of fractions involving \alpha (x-height), 
\beta (asc + desc), \gamma (only desc) and \delta (only asc).
Then try adding superscripts (^{2}) or subscripts (_{0}) as well.

The trick is finding default parameters, which are big enough to 
accommodate standard stuff x^2 or x_0 without any extra shifting,
but which do not leave too much or too little optical gaps either.

Ulrik Vieth.

P.S: If you are really interested, I once wrote a paper, where I 
discussed the reasoning how the values for math font parameters
might be determined.

On 18.01.2015 19:17, Emil E wrote:
> Hello,
> I'm typesetting some simple math problems/solutions using LuaLaTeX,
> and I'm having trouble with the spacing between the numerator and
> division bar in \frac environments.
> I've attached a MWE below, along with an image showing the my
> output of the MWE.
> I apologize in advance if my image links don't follow the proper
> etiquette for this mailing list.
> \documentclass[11pt]{article}
> \usepackage{amsmath,amsthm,amssymb,amsfonts}
> \usepackage{fontspec}
> \setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
> \usepackage{unicode-math}
> \setmathfont{TeX Gyre Pagella Math}
> \begin{document}
> $$
> \frac{xxxxxxLLLLLL}{xxxxxxTTTTTT} \frac{2(x-1)-(x^{2}-1)}{(x^{2}-1)(x-1)}
> $$
> \end{document}
> Here is a screenshot of the PDF output on my system.
> Note how the spacing between the bottom of the L and the division bar
> is about 2-3x larger than the spacing between the top of the T and
> division bar.
> https://i.imgur.com/RWeuSVA.png
> The bizarre spacing occurs regardless of font, or the packages
> fontspec, unicode-math, or the AMS packages.
> This seems to indicate that it's a problem with LuaLaTeX itself.
> I've been able to fix the fraction spacing by defining a new \frac
> environment that manually adjusts the spacing of the numerator,
> but that's a "hacky" solution that I don't like using.
> PDFLaTeX shows proper spacing using the same math code, however
> I'd like to stay with LuaLaTeX instead of reverting to PDFLaTeX.
> Is there any way to fix this spacing?
> Below are some details of my set-up:
> Arch Linux x64
> Running TeXLive 2014, installed manually and up-to-date
> LuaLaTeX version is beta-0.79.1 (TeX Live 2014) (rev 4971)
> Compiling through TeXStudio 2.8.8

More information about the luatex mailing list