In the following MWE:
\documentclass{article}
\usepackage{mathpazo}
\begin{document}
$\frac{1}{2}$
\end{document}
the fraction bar is a little bit too close to the denominator, see the screenshot:
Is there a reason for this behaviour, and can one adjust the position of the line? I don’t think that it should be like this, since when using lmodern
instead, the bar is (as far as I can tell) exactly in the middle, see the second screenshot:
Best Answer
Let’s briefly go through how TeX creates a fraction (many details will be ignored for the sake of simplicity). First, TeX needs to know where the fraction bar should be drawn and how thick it should be. These are controlled by
\fontdimen
parameters, which are decided by the font designer(s) (but users can change them later). The vertical position of the bar corresponds to\fontdimen 22 of family 2
, while the thickness corresponds to\fontdimen 8 of family 3
. Then, TeX needs to shift the numerator and denominator up and down from the “baseline” in order to stack them into a fraction. The parameters controlling numerator are\fontdimen 8, 9, 10 of family 2
, while those for denominator are\fontdimen 11, 12 of family 2
. Note: It is up to the font designer(s) to set appropriate values to these parameters so the results will be visually pleasing in most cases.This is because
mathpazo
uses identical values for many parameters as Computer Modern Math does. These values work fine with Computer Modern (and also Latin Modernlmodern
). But Palatino-like designs have taller “bodies”, which often need more generous spacing. So these shifting amounts (designed for Computer Modern) are probably not adequate for Palatino.You don’t really want to adjust the position of the fraction bar (because
\fontdimen 22 of family 2
affects a lot of other different things). Instead, you can enlarge\fontdimen 11, 12 of family 2
to cause the denominator to be shifted down a bit more.David’s answer shows how you can assign new values to
\fontdimen11\textfont2
. The drawback is that this assignment is very low-level (the lowest level of TeX programming). In particular, this only works for one font size (namely, the\normalsize
10pt in this case).A slightly higher-level solution is to use
\DeclareFontShape
within the LaTeX NFSS (New Font Selection Scheme). The syntax isBut IMO this sort of code should appear in packages. Well, IMO this sort of code should never be needed if the parameters in the font were adequate in the first place.
Well, just as David’s answer also explained, if the bar is exactly in the middle of
1
and2
, then it certainly cannot be in the exact middle of1
andx
, nor can it be in the exact middle of1
and(N)
. Remember, it’s about visual balance in an infinite number of cases, not about mathematical exactness.My recommendation
Switch to
newpxtext
andnewpxmath
if you can. These newer packages are actively maintained. I also helped refinenewpxmath
in 2019, which dealt with the positions of numerator and denominator. The details are here: https://tex.stackexchange.com/a/509092 which IMO suit your current need as well. I tried to find balance between (1) equalized spacing around the fraction bar, (2) uniform baseline for numerator, and (3) uniform baseline for denominator. It can never be “perfect”, but I think the results are visually pleasing.In conclusion, just use
\usepackage[fracspacing]{newpxmath}
instead of\usepackage{mathpazo}
should do the trick.If you want to stick with
mathpazo
, then:If you still want to use
mathpazo
, then here is the LaTeX NFSS code you can use:The two values
0.789
and0.798
are taken fromnewpxmath
. If memory serves me correctly, they should be adequate for Palatino’s long ascenders and descenders. You are welcome to adjust them to your need, and even adjust\fontdimen 9, 10, 12
as well.