7

I feel a bit weird because this is a really simple issue that apparently nobody has brought up so far but I find that very simple fractions produce output that looks vertically unbalanced. The following example uses Iwona as math font because there it's really obvious – with the gap between numerator and fraction line being almost 1.5 times as large as the space between denominator and the line.

\documentclass{standalone}
\usepackage[math]{iwona} % Iwona as math font
\begin{document}
$\frac{1}{2}\frac{1}{N}$
\end{document}

1/2 1/N in Iwona Math

It's not completely a font issue though. I measured Computer Modern and the imbalance factor there is about 1.3, too.

1/2 1/N in Computer Modern

I find this visually unpleasant and somewhat surprising – given how much LaTeX is hailed for its math typesetting, there is probably a reason for this imbalance. Either way, is there an easy way to fix this feature?

1 Answer 1

8

The default settings don't pack the numerator and denoimnator as close to the line as possible which gives a more consistent layout. In 1/2 the gap from the 1 to the bar is, as you say larger than the gap from the bar to the 2, but in 1/x the larger gap is below the bar, however 1/2 and 1/x are aligned consistently.

However you can change the font params to get a tighter spacing:

enter image description here

\documentclass{article}
\usepackage[math]{iwona} % Iwona as math font
\begin{document}
$a$
\typeout{\the\fontdimen9\textfont2}

$1+\frac{1}{2}+ \frac{1}{x}+\frac{1}{N}+\frac{1}{N^2} + \frac{1}{(a+b)}$


\fontdimen9\textfont2=2pt

\typeout{\the\fontdimen9\textfont2}
$1+\frac{1}{2}+ \frac{1}{x}+\frac{1}{N}+\frac{1}{N^2} + \frac{1}{(a+b)}$


\end{document}

See This answer for a list of font parameters.

5
  • Wow, nice! So the fractions are typeset intentionally for the cap height to be slightly off so the x-height will look better, did I get that right? Oh and for the record, I found a value of 3.5pt to work well for Iwona. How do I set this for my whole document though? I tried adapting tex.stackexchange.com/a/96058/13450 but without success.
    – Christian
    Jul 6, 2013 at 18:00
  • @Christian well the font designer (or at least the author of the tex setup) sets these, but tex doesn't try to normalise the "gaps" for normal sized arguments it just moves the baselines by font-specified amounts. \AtBeginDocument{\setbox0{$$}\fontdimen9\textfont2=3.5pt} should do it (you need a math list to trigger the initial math setup before you change it, which is why there is an $a$ in my answer doing it in a box stops it printing. Jul 6, 2013 at 18:09
  • Ok, finally understood why I didn't get it to work. I assumed inline and displayed equations to be equally affected. This is not the case. In fact, using the same \fontdimen statement in a displayed equation doesn't seem to do anything :/
    – Christian
    Jul 6, 2013 at 21:47
  • 1
    @Christian \fontdimen8\textfont2=1pt shrinks display math Jul 6, 2013 at 21:56
  • Great, this indeed works perfectly! Again, for the record: \fontdimen9\textfont2=3.5pt\fontdimen8\textfont2=5pt.
    – Christian
    Jul 6, 2013 at 22:41

You must log in to answer this question.

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