This answer encounters a bug rendering arrays on IE, viz. compare two thick hlines in the first pic (on IE 8) vs. the correct rendering in the second pic (on Opera 12). Is there a workaround?

enter image description here enter image description here

Also note that the hlines extend a bit too far to the right on Opera (bottom). Ditto for the vlines, which stick out from the bottom.

This happens with fractions (\frac) as well, if you look closely around the site (and others). I played around with this quite a bit awhile back and couldn't find an obvious way around it. (By the way, I've noticed this behavior in Firefox, Safari and Chrome, all on Mac OS X.) –  cardinal Jul 8 '12 at 22:09
add comment

2 Answers

The issue here has to do with how the browsers fit the mathematics to the pixels of the screen. For characters in a font, most browsers use antialiasing to help perform "sub-pixel" positioning, allowing characters to appear to be positioned anywhere, without having to line up with the pixels exactly. The horizontal and vertical lines, however, are not characters from a font (they are actually implemented as borders of elements with given dimensions), and so they are not anti-aliased. If a horizontal line is asked to be placed so that its has to be divided between two pixels, the browser has to decide which pixels to use for it. If it is mostly in the upper pixel, that pixel is used; if mostly in the lower one, that pixel is used; but if it is nearly half in each, what to do then? Some browsers show both.

I believe that is what you are seeing here. If you inspect the DOM elements using Firebug or some other similar tool, you will see that the heights of all the horizontal lines are exactly the same in the CSS that controls them. The different sizes are purely the result of the browser attempting to render those sizes in the pixel grid that it has available. The result is very much dependent on the position of the lines compared to the pixel grid of the screen (which is why only some of the lines are thicker). If you zoom the page in or out, you will get different ones that are too thick. I've even seen them change as the page is scrolled in some browsers.

I have looked into this issue before, and there seems to be no easy answer for it. The situation is particularly delicate for sizes that are near one pixel, as getting an extra pixel in that case is very apparent. On the other hand, if the size of the line is made less than a pixel in order to reduce the chances of the extra pixel, some browsers will drop the line entirely (thinking it is less than a pixel so shouldn't be shown). In general, MathJax makes the lines slightly larger to avoid the disappearing lines, at the expense of some wider lines like the ones you are seeing. Firefox is particularly prone to this excess size, and IE to both the dropping and enlarging of the lines.

Thanks for the explanation. Is is possible for me to specify in MathJax the thickness of the horizontal and vertical lines and, if so, what thickness would minimize the probability of such problems? –  Bill Dubuque Jul 10 '12 at 15:29
For fractions, you can use { ... \above 2px ... } to make a 2-pixel fraction bar. You can define a macro to make it work like \frac if you wish. Unfortunately, MathML doesn't include a mechanism for specifying the width of the rules in an mtable, so there is no way to specify that. As for the optimal size, if I knew a better size, I would have had MathJax use that. But you can certainly try some other thicknesses and see how that works. –  Davide Cervone Jul 10 '12 at 17:36
add comment

This is not an answer, but rather an additional data point. I have observed similar behavior with \frac{} in multiple browsers on multiple websites (including outside SE) using MathJax.

Below are some examples using Firefox 13.0.1 on Mac OS X (10.6.8). Both seem to render correctly on current versions of Safari and Chrome for Mac.

Example 1

First, we have the table from Bill's original post. Note the different placement of the thicker lines.

Table hlines

Example 2

Here is an example of similar behavior with \frac{} taken from this question. Notice the differences in thickness, including those in the right-hand "Related" bar.

You can click on the image to see the full-size version.

fraction example

add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .