Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equation numbering and width: fit-content/max-content/min-content #428

Closed
pkra opened this issue Apr 3, 2013 · 9 comments

Comments

Projects
None yet
4 participants
@pkra
Copy link
Member

commented Apr 3, 2013

Via the user group we got [this example http://jsfiddle.net/8Wnxk/36/]. Can we do something about it?

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2013

The problem is more general and not specific to Firefox. Basically, the CSS layout algorithm used in browsers relies on min/max intrinsic widths. Some widths are modified by MathJax when it typesets the equations. Since there is no communication with the browser layout rendering, the final rendering may be wrong.

This issue prevents MathJax's line breaking algorithm to work correctly in this example:

<div style="width: 100px;">
  <table>
    <tr>
       <td>
         <math>
           <mi>x</mi>
          <mo>+</mo>
          <mi>x</mi>
          <mo>+</mo>
          <mi>x</mi>
          <mo>+</mo>
          <mi>x</mi>
          <mo>+</mo>
          <mi>x</mi>
          <mo>+</mo>
          <mi>x</mi>
          <mo>+</mo>
          <mi>x</mi>
         </math>
       </td>
     </tr>
  </table>
</div> 
@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 4, 2013

Under certain circumstances (mostly when there is an equation tag), MathJax will make its displayed equations inside a <div> with width:100% and will center the equation using absolute positioning within that DIV. This works as long as the container for the <div> has an actual width, but if it is "shrinkable" as it is with the Mozilla CSS attributes in the jsFiddle example, and in the <td> in Fred's example, the container has no fixed width, and so width:100% can end up being 0 (or the width of whatever other content is in the container). Because of the positioning, the equation's width is essentially 0, and so doesn't cause the container to require any width.

One solution would be to set min-width for the <div> that has width:100% so that it will have at least the width of the equation and label. I think that would clear up the problem of having the container shrink too much.

Fred's line-breaking issue is more complicated, since MathJax tries to find out the width of the containing element in order to know where to do its line breaking. For something like a <td> with no other content, that doesn't work well, and the line breaking can get the wrong width to break at. I'm not sure what the best solution is there. Personally, I think displayed equations are inappropriate in such situations (though you could use \displaystyle to get the display layout without the centering and other formatting), but that won't stop people from doing it anyway.

@aleth

This comment has been minimized.

Copy link

commented Apr 5, 2013

Only commenting to subscribe to this thread, as this issue also affects the Instantbird Mathjax add-on (for certain message styles).

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 5, 2013

FYI, you can use the "Watch thread" menu item at the bottom to subscribe to the thread. No need to actually post.

@ghost ghost assigned dpvc Apr 15, 2013

dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 29, 2013

Davide P. Cervone
Add min-width to displayed equations with labels so that they cause t…
…heir containers to have non-zero width (like when they are in a table cell). Resolves issue mathjax#428.
@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 29, 2013

The issue428 branch of my fork of MathJax includes a fix for this. It uses min-width to force the width of the math to be its minimum width when the equation is tagged or numbered.

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2013

=> Ready for release, in testsuite

The test will be

LaTeXToMathML/issue428.html

dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 29, 2013

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 29, 2013

=> Merged

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2013

I get a processing error with the following code:

 <math><mtable><mlabeledtr><mtd/></mlabeledtr></mtable></math>

but only when it is merged in the develop branch. HTMLCSS.Em is called with min = stack.bbox.w undefined. Perhaps it's related to issue #364, where the bbox setup is modified.

dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 30, 2013

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 30, 2013

OK, thanks. There was a variable scope issue reported by the packer when I went to make the packed version, and I had to change the name of a variable. Missed one instance. Fixed in the develop branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.