# \lvert…\rvert is making bars that are too tall

Consider \kappa(x) = \left\lvert\frac{y''(x)}{\left(1+y'(x)^2\right)^{3/2}}\right\rvert:

$$\kappa(x) = \left\lvert\frac{y''(x)}{\left(1+y'(x)^2\right)^{3/2}}\right\rvert$$

The vertical bars are much too tall on both sides, protruding well past the top of the numerator of the fraction. Here is a screenshot:

My browser is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0

Is this an error in my request, or in MathJax's rendering?

• It looks the same for me on Chrome 32.0.1700.76 m. It appears to be using the maximum of the heights of the numerator and the denominator. – Antonio Vargas Jan 20 '14 at 18:30
• Looks the same here. I did a quick check in answer box, and the same is the case with other types of brackets (like () and {}). The reverse seems to be the case with \langle and \rangle (ie, they fit the numerator, but are too small for the denominator). – Tobias Kildetoft Jan 20 '14 at 19:01
• @TobiasKildetoft, the reason that \langle and \rangle are different is that they are not infinitely stretchable, as the vertical line is. MathJax only has 5 sizes of this symbol, and this particular fraction is larger than the largest one. MathJax uses the largest it has available, but as you point out, it only covers the numerator and part of the denominator. – Davide Cervone Jan 20 '14 at 20:46
• Here's how it renders in regular LaTeX. – Alexander Gruber Jan 20 '14 at 21:47

This is, in fact, correct behavior. Stretchy delimiters are centered on the "math axis" (which is a line at about the height of a minus sign), and extend equally above and below that axis. Fractions are placed so that their fraction line is on the math axis. So when a fraction has a denominator that is larger in height than the numerator (as in your case), the delimiters will extend beyond the numerator.

If you want to have the delimiter only cover the fraction exactly, you could use \vcenter around the fraction, but I don't think you'll like the results.

$$\kappa(x) = \left\lvert\vcenter{\frac{y''(x)}{\left(1+y'(x)^2\right)^{3/2}}}\right\rvert$$

Note that the fraction line is no longer on the math axis, which looks strange. (In actual $\rm\TeX$, you would need to use \vcenter{\hbox{$\displaystyle...$}} not just \vcenter, but in MathJax, you can get away with just the \vcenter.)

If you wanted the fraction to line up on the math axis, you would have to reposition it by hand, say using \lower.4em{...} around the \left...\right group:

$$\kappa(x) = \lower.4em{\left\lvert\vcenter{\frac{y''(x)}{\left(1+y'(x)^2\right)^{3/2}}}\right\rvert}$$

This looks unbalanced to me, but you may feel otherwise. (In real $\rm\TeX$, you would need to use \lower.4em\hbox{$\displaystyle...$} rather than just \lower.4em.)

Addendum: As Alexander Gruber points out, the $\rm\TeX$ output for this expression is

which has the denominator more the same size as the numerator. The reason for the difference, here, is the placement of the 2 in the superscript in the denominator. The $\rm\TeX$ version is lower, which gives the expression within the \left...\right less height, so a normal sized parenthesis can cover it (rather than the larger one needed by MathJax). It is that larger parenthesis in MathJax, and the accompanying shift in the 3/2 power, that causes the denominator to be so much larger than the numerator.

If you were to raise the square slightly in $\rm\TeX$, then the results would be the same as the MathJax output (this is an image from $\rm\TeX$):

So why is the square in a different position? There are several issues involved, but one important one is that $\rm\TeX$ actually uses different fonts for the super- and subscripts compared to the base, and these each have different "font dimensions". These are values that $\rm\TeX$ uses to determine the positions of things like super- and subscripts, or the widths of fraction lines, etc. MathJax, however, only has one font that it scales for use with superscripts (this is a compromise to reduce the amount of data that has to be downloaded to view the math). So the font dimensions are also scaled. It turns out that the scaled values are not always the same as the values that are in the smaller fonts that $\rm\TeX$ use, so there are some differences in placement like this. (There are also other technical causes, but there is no need to go into that here.)

In any case, one possible work-around would be to not use \left...\right in the denominator but instead select the desired size for the parentheses directly with \bigl and \bigr, as in

\kappa(x) = \left\lvert\frac{y''(x)}{\bigl(1+y'(x)^2\bigr)^{3/2}}\right\rvert

which produces:

$$\kappa(x) = \left\lvert\frac{y''(x)}{\bigl(1+y'(x)^2\bigr)^{3/2}}\right\rvert$$

I will look into whether there is a better approach to the font dimensions in MathJax, but if I do, that won't be available for a while.

• Thanks for your explanation. Alexander Gruber's screenshot of $\LaTeX$ output looks more the way I expect. The fraction bar is centered, but the numerator and denominator are more similar in size. Can you explain why this is? – MJD Jan 21 '14 at 5:22
• @MJD I'm not sure how to define "correct behavior" here, but TeX is suppressing the \left and \right within the denominator. – Scott H. Jan 21 '14 at 8:08
• @ScottH., I've added some additional information to the end of my answer that explains the difference between TeX's and MathJax's output in this case. – Davide Cervone Jan 21 '14 at 15:07
• @MJD, I've added a suggested work-around to my answer that produces a result more in line with what I think you are looking for. – Davide Cervone Jan 21 '14 at 15:08
• Thank you again for your time and effort. It is always a pleasure to learn from your answers. – MJD Jan 21 '14 at 15:13
• @DavideCervone Thanks for taking the time to provide the additional explanation. – Scott H. Jan 21 '14 at 18:30