Google Groups

Re: [mathjax-users] column spanning

Davide Cervone May 23, 2012 9:40 AM
Posted in group: MathJax Users
It appears that column spanning isn't supported currently in the mathml parsing?

Sadly, yes, MathJax doesn't yet do column or row spanning.  It is one of the important features that is missing from mtable in MathJax at the moment (there are a few other as well).

I ask as the MathJax enabled version of the spec runs some xslt to
rewrite mathml3 and content mathml features to presentation mathml2.
For mstack/msline and it uses columnspan and this currently fails.

Yes, I noticed that, and thought it was pretty clever, though I did note that MathJax wouldn't be able to handle it.

Actually it uses a column span and then a style attribute to put a css
border for the rule as in  (3) in the test file below.
That works in firefox native mathml, but isn't ideal actually as there
is no _requirement_ for a mathml processor to support style. I would
switch to a horizontal stretched line operator or anything else if it

It is not easy to get what you ask, but I present you with two possibilities.  The first doesn't use a table at all, which will get the baseline correct for in-line math:

  <mpadded width="0" height=".925em" voffset=".85em" lspace="-1width">
    <mpadded background="black" height=".075em">

This presents the number as is, and then "backspaces" the horizontal bar over top.  The phantom gets an element with the proper width, then the inner mpadded make a black line of that width and height .075em.  The outer mpadded moves that line over top of the preceding decimals, while taking up no horizontal space itself, but extending the vertical space to include the overbar.  A terrible hack, but workable.  If you don't want to use the mphantom for getting the width, you could use a width of .5em per digit and multiply by the number of digits.

If you want to keep the mtable, you can do something similar by "faking" the column span:

<mtable xmlns:m="" columnspacing="0em">
    <mpadded width=".5em" voffset="-.3em">
      <mpadded background="black" height=".075em">

This uses the same trick for getting a black line of the proper width, and uses an mpadded to allow it to extend over the right-hand side of the (one) column that it occupies.  It also positions it vertically, since there is some space between the rows, so that the line is closer to the numbers.  This will be visually OK, but takes up a lot more vertical space than needed, since the upper row still has the height of a row.

It seems the content of the style doesn't survive mathjax processing.

Actually it does, but the problem is that the cell is zero width since it has no content, and so the border doesn't show up.  MathJax doesn't really have an element that correctly corresponds to the full-size mtd that you have in mind.  This is another deficiency in the MathJax table model that needs work.  (It was a real bear to implement the MathML mtable layout in HTML with its various column width options and still be able to allow percentage widths to work dynamically as the page size changes.  I'm afraid there is still some work to be done.)

Especially in the case of msline (ie an inter-row rule spanning some
but not usually all of the columns)  I'd be interested to know if
there is _any_ javascript/css I could inject after mathjax has
finished to make a reasonable rendering. This case may? be easier than
a general column spanning code.

See if the examples I gave you above will work for you.  If not I may be able to come up with something else.