1

I've never noticed it before, but LaTeX puts a lot more space between the numerator and the bar than it puts between the bar and the denominator. Now maybe this makes sense for more complicated fractions than a simple 1/2, but it looks quite wrong to me. Now that I've noticed, I can't unsee it. Why is this the default behaviour of LaTeX? Can I do anything about it?

\documentclass{article}

\begin{document}
    \[\frac{1}{2}\]
\end{document}

enter image description here

  • 7
    try \frak{x}{y} and \frak{pq}{bd} and you should see "more uniform" spacing. (better yet, put parentheses around the numerators and denominators.) fractions are not just digits. the baselines of the numerator and denominator are set so that all one-level occupants will be visually on the same baselines in adjacent fractions. (things get a bit more complicated when sub- and superscripts are involved.) – barbara beeton Jul 26 '15 at 14:24
  • 1
    @barbarabeeton, you probably mean \frac{x}{y} and frac{pq}{bd}. – Zarko Jul 27 '15 at 22:07
  • @Zarko -- yes, of course. (can i use as an excuse that i'm in germany rather than at home in the us? i guess not.) thanks for the correction. – barbara beeton Jul 28 '15 at 14:01
1

Barbara Beeton explains in a comment that this behaviour is intended to give good-looking fractions in typesetting situations where multiple fractions are near to one another, by setting the baselines of text in the numerator and denominator such that the various baselines of nearby fractions are lined up (even though they might contain a variety of different types of mathematical text). This led me to create a macro that attempts to defeat LaTeX's automatic vertical spacing so that fractions like 1/2, consisting of simple digits, are equally spaced above and below the bar. Looking carefully at the results, it seems to make the spacing above and below the bar much closer to equal, although there is still a small difference; I don't know where the remaining difference comes from, but you would have to look very closely to see it [per comment: probably due to "overshoot" at the top of the rounded "2" glyph; likely of no concern]

(Edited to provide an improved version)

\documentclass{article}

\usepackage{pgfmath, xparse}

\newlength{\MathStrutDepth}
\newlength{\MathStrutHeight}
\settoheight{\MathStrutHeight}{$\mathstrut$}
\settodepth{\MathStrutDepth}{$\mathstrut$}

\newlength{\NumeratorDepth}
\newlength{\DenominatorHeight}
\newlength{\DepthNegativeDifference}
\newlength{\HeightPositiveDifference}
\newlength{\NumeratorBaselineCorrection}
\newlength{\DenominatorBaselineCorrection}

\newlength{\AdditionalEVSFracVerticalSpacing}
\setlength{\AdditionalEVSFracVerticalSpacing}{0.05mm}

% Fraction with equal top-and-bottom vertical spacing around the bar.
% Suited only to simple fractions that do not appear near other fractions.
% When used alongside other fractions, numerator and denominator baselines
% might not be aligned, which might give ugly results.
\NewDocumentCommand\EVSFrac{omom}{%
    \IfValueTF{#1}%
              {\settodepth{\NumeratorDepth}{$#1$}}%
              {\settodepth{\NumeratorDepth}{$#2$}}%
    \IfValueTF{#3}%
              {\settoheight{\DenominatorHeight}{$#3$}}%
              {\settoheight{\DenominatorHeight}{$#4$}}%
    \pgfmathsetlength%
        {\DepthNegativeDifference}%
        {\NumeratorDepth - \MathStrutDepth}%
    \pgfmathsetlength%
        {\HeightPositiveDifference}%
        {\MathStrutHeight - \DenominatorHeight}%
    \pgfmathsetlength%
        {\NumeratorBaselineCorrection}%
        {\AdditionalEVSFracVerticalSpacing + \DepthNegativeDifference + \HeightPositiveDifference}%
    \pgfmathsetlength%
        {\DenominatorBaselineCorrection}%
        {-\AdditionalEVSFracVerticalSpacing}%
    \def\Numerator{\raisebox{\NumeratorBaselineCorrection}{$#2$}}%
    \def\Denominator{\raisebox{\DenominatorBaselineCorrection}{$#4$}}%
    \frac{\Numerator}{\Denominator}%
}

\begin{document}
    \[\EVSFrac{1}{2}\]
\end{document}

enter image description here

  • 1
    hypothesis: tex sets the height or depth according to the metrics in the font. a rounded top or bottom of a glyph is often allowed an "overshoot" that makes the image extend higher or lower than the assigned dimension indicates. go to ilovetypography.com/2009/01/14/inconspicuous-vertical-metrics and scroll down to the "xo" image for a picture. – barbara beeton Jul 27 '15 at 9:48
  • @Hammerite : It's perfectly okay to ask and answer your own question on a Stack Exchange site, see Can I answer my own question?. Please accept your answer to close the question. – Bobyandbob Nov 5 '17 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.