# How and whether to fine-tune the vertical placement of a fraction line

This is a question about the aesthetics of mathematical typesetting, as well as a technical question about LaTeX.

I'm writing a lot of expressions like this:

(\log\frac{p_{i\to j}}{p_{j\to i}} in a display math environment.)

This looks odd to me, because of the very large gap between the fraction line and the denominator, compared with quite a small gap between the line and the numerator.

I realise that in some sense that gap needs to be there in order to accommodate taller characters like 'A' or 'b', but since there are no such letters in my expression it seems like it might look better if the spacing were different.

So my questions are (with roughly equal priority):

1. Should I be messing with this? Am I right in thinking the expression looks unbalanced, or should I just trust the algorithm's designer (presumably Knuth) to have made the right decision about how to typeset this?

2. If I should change it, what should change exactly? Should the line be lower, or should the denominator and/or numerator be higher up?

3. If changing it isn't a terrible idea, what is the best way to affect such a change?

I believe this is not a duplicate of How to vertically center the fraction line?, since that question is about how the spacing relates to the font, rather than to the actual characters used in the numerator and denominator.

• Please see if this helps -- tex.stackexchange.com/q/70527/34618 and this tex.stackexchange.com/q/72819/34618 Feb 2 '14 at 5:35
• @Jesse those questions help a little, but they're only tangentially related, and don't address the aesthetics/best-practice aspect of my question. Feb 2 '14 at 5:44
• Great, the focal point is clear. Feb 2 '14 at 5:50
• How about \log\frac{p(i\to j)}{p(j\to i)} , so you don't have subscripts in the fraction? This might be easier to read, unless it violates some notation convention important in your discipline. Feb 2 '14 at 16:05
• Feb 2 '14 at 21:31

1. Usually I don't bother about these things, except when the result is very ugly.

In this case, the result is not so ugly, but effectively the fraction looks a bit unbalanced.

2. I would live with it, but if you really can't, this can be a way to achieve a more balanced fraction.

First of all, let's have a closer look at the result in all styles (displaystyle, textstyle, etc.)

IMHO, the latter two can be OK, while the former two need both the denominator and the numerator to be raised up.

The following can be a solution (a new command \bfrac, with the meaning "balanced fraction"):

\DeclareRobustCommand{\bfrac}[2]{%
\mathchoice{\frac{\raisebox{0.1ex}{$#1$}}{\raisebox{0.4ex}{$#2$}}}%
{\frac{\raisebox{0.4ex}{$\scriptstyle#1$}}{\raisebox{0.1ex}{$\scriptstyle#2$}}}%
{\frac{#1}{#2}}%
{\frac{#1}{#2}}%
}


MWE

\documentclass{article}
\usepackage{amsmath}

\DeclareRobustCommand{\bfrac}[2]{%
\mathchoice{\frac{\raisebox{0.1ex}{$#1$}}{\raisebox{0.4ex}{$#2$}}}%
{\frac{\raisebox{0.4ex}{$\scriptstyle#1$}}{\raisebox{0.1ex}{$\scriptstyle#2$}}}%
{\frac{#1}{#2}}%
{\frac{#1}{#2}}%
}

\begin{document}
$\displaystyle{\frac{p_{i\to j}}{p_{j\to i}}}\quad \textstyle{\frac{p_{i\to j}}{p_{j\to i}}}\quad \scriptstyle{\frac{p_{i\to j}}{p_{j\to i}}}\quad \scriptscriptstyle{\frac{p_{i\to j}}{p_{j\to i}}}$

\bigskip

$\displaystyle{\bfrac{p_{i\to j}}{p_{j\to i}}}\quad \textstyle{\bfrac{p_{i\to j}}{p_{j\to i}}}\quad \scriptstyle{\bfrac{p_{i\to j}}{p_{j\to i}}}\quad \scriptscriptstyle{\bfrac{p_{i\to j}}{p_{j\to i}}}$
\end{document}


You can compare the output:

• May be using ex units (or mu/em) you can provide a more “secure” solution. Feb 2 '14 at 10:30
• in the question, the fraction is set next to \log. context matters. although from the code, the vertical position of the fraction rule isn't adjusted, only that of the numerator and denominator, the effect of setting it in smaller sizes appears to lower the rule, which would look very odd in context, especially if it happens to be followed by, say, a plus or minus, which has a very strong horizontal at the math axis. it would be best if the fraction rule can be kept, even artificially, at the math axis. Feb 2 '14 at 14:45