# In MathJax, how can I get the index of a cube root of a tall expression to be at the right level?

In MathJax, the cube root of a displayed fraction comes out like $$\sqrt[3]\frac ab .$$ Typographically, there are four things wrong with this. The main one is that the $$3$$ is too low. It should at the top of the surd symbol, not near the middle. Is there a workaround for this?

The other issues, which I do not expect a workaround for, are:

(1)$$\;$$ the $$3$$ is too small

(2)$$\;$$ the bottom of the surd symbol is too deep

(3)$$\;$$ the fraction symbols are not well balanced about the fraction bar (i.e. the fraction bar is too low)

(4)$$\;$$ the vinculum is redundant (of course, the \sqrt instruction calls for a vinculum, but there is no option to use the \surd instruction for a display fraction or with a pre-index).

While there are certainly different philosophies about what is the most aesthetic typesetting layout, MathJax attempts to reproduce as closely as it can the results that you would get from actual $$\rm\LaTeX$$. It is certainly imperfect in that, but the measure of what is "correct" for MathJax output (on $$\rm\LaTeX$$ input) is actual $$\rm\LaTeX$$ output.

With that criterion, I would say all four of your complaints are incorrect.

Here is the $$\rm\LaTeX$$ output for your expression:

and this is the MathJax output in Firefox with HTML-CSS output (the results can vary across browsers and operative systems, and the CSS involved in the page).

While not identical, these are very close, and indicate that all the things you complain about are in the actual $$\rm\LaTeX$$ output, and MathJax is reproducing those properly. The main difference is actually in the font used for the "3" (not the size or vertical placement). $$\rm\TeX$$ uses different fonts for each of the text, script, and script-script sizes (the smaller sizes are a bit wider than the standard sized font), while MathJax uses scaled versions of the main text-sized font instead (to reduce the number of fonts that need to be sent over the network to your browser). There is also a slight horizontal position difference horizontally here, but not the vertical difference that you are looking for. That has to do with the fact that MathJax doesn't have all the internal information that $$\rm\LaTeX$$ does, so the positioning algorithm in MathJax is not actually the same as in $$\rm\LaTeX$$; some improvement may be possible there.

As for (2), the surds come in five fixes sizes, plus pieces that can be used to construct arbitrarily large ones when the content is larger than the largest available fixed size. When the content of the root is between two of the fixed sizes, the larger size is selected, and that surd is centered on the content. That may mean that the surd extends below the bottom of the fraction, as it does in this case. In the image below, I have put a red bounding box around the fraction and a green one around the root (and drawn the root in green as well, so it is easier to see the relationship between the red and green boxes). Note that the green is reasonably centered on the red.

As for your third point, the placement of the numerator and denominator are as in $$\rm\TeX$$. The reason it seems unbalanced to you is that the $$a$$ has no descender while the $$b$$ has an ascender. That does not mean the $$a$$ should be closer to the fraction bar. Because fractions may appear next to each other (when multiplied, for example), $$\rm\TeX$$ goes to great pains to make sure the baselines of the numerators and denominators of adjacent fractions are the same. That is,

$$\Large \frac{a}{b} + \frac{y}{z}$$

should have that $$a$$ and $$y$$ on the same baseline, and the $$b$$ and $$z$$ on the same baseline. So the fraction bar is not necessarily in the middle of the empty space between the actual "ink" of the numerator and denominator.

Finally, for your fourth point, $$\rm\LaTeX$$ uses the vinculum, as you point out, so MathJax does as well. I suppose you could do $$\sqrt[3]{\vphantom{\frac{a}{b}}}\frac{a}{b}$$, to get

$$\sqrt[3]{\vphantom{\frac{a}{b}}}\frac{a}{b}$$

but I wouldn't recommend it, as it will be less accessible to those with assistive technology.

The upshot is, the MathJax output correctly mirrors the $$\rm\LaTeX$$ output, as it is intended to. Your own choices are personal preferences, but they are not the choices that Donald Knuth made for $$\rm\LaTeX$$. To claim that they are not "typographically correct" is to disregard the fact that $$\rm\LaTeX$$ is a publishing industry standard, and has been for decades.

There is $\root{\displaystyle{3}}\of{\frac{a}{b}}$ that will make the $$3$$ larger:

$$\root{\displaystyle{3}}\of{\frac{a}{b}}.$$

Don't know if this substantially better. If your custom is to use the \sqrt[#1]{#2} construction instead of my preferred (straight from the $$\TeX$$book) \root{#1}\of{#2} that probably works too.

Undoubtedly other finetuning is also possible.

Experimenting with the \raise[n pt]{} construct:

\root{\raise2pt{\displaystyle{3}}}\of{\frac{a}{b}}

$$\root{\raise2pt{\displaystyle{3}}}\of{\frac{a}{b}},$$

\root{\raise4pt{3}}\of{\frac{a}{b}}

$$\root{\raise4pt{3}}\of{\frac{a}{b}}.$$

• Normally the $3$ of a cube root is in sub/superscript size, but \displaystyle gives its normal in-line size. Exactly like the difference between \frac and \dfrac when typesetting fractions in-line. I'm fairly sure that extra 'd' stands for 'display'. It should be possible to specify a different font size (if one is available), but that becomes kludgier. Don't know how to lower/raise the surd, and that may have other side effects. I would not worry about it too much here. When producing a document I might dig deeper, or ask at Tex.SE- there are very competent people there :-) – Jyrki Lahtonen Jan 14 at 17:02
• Well, it's gone from $$\sqrt[?]{\frac ab}$$ (for those with poor eyesight) to a compressed version of $$3\sqrt{\frac ab}.$$ But anyway, the primary issue (which I can't illustrate) was the elevation of the $3$, not its size. – John Bentin Jan 14 at 17:25

From robjohn's answer to a related question, I found a workaround that solved the main issue and the first of the secondary issues. Using $$\sqrt[\raise{7pt}\Large3]{\frac ab}$$, we get $$\sqrt[\raise{7pt}\Large3]{\frac ab}.$$

• Good digging! (+1) That $3$ is too high for my taste, but if that's what you want :-). The box created by a displayed fraction is fairly tall, and the surd needs to cover that. I don't think it dips too low, but, degustibus non est disputandum. – Jyrki Lahtonen Jan 14 at 22:10