No width for equations with equation numbers?

108 views
Skip to first unread message

ael...@yahoo.co.uk

unread,
Mar 25, 2013, 5:23:15 AM3/25/13
to mathja...@googlegroups.com
Which configuration option(s) do I need to set to ensure the HTML generated for numbered equations has a width set?

The problem I am running into is that the HTML generated by MathJax is within a DOM element that tries to adjust its size to the content. This works perfectly as long as equations are not numbered. When they are numbered it seems the width of the components (the equation, and the equation number) is zero, so they are displayed overlapping and the parent element can't set its size correctly.

Peter Krautzberger

unread,
Mar 29, 2013, 11:54:56 AM3/29/13
to mathja...@googlegroups.com
Could you provide a live page that we can look at?


On Mon, Mar 25, 2013 at 2:23 AM, <ael...@yahoo.co.uk> wrote:
Which configuration option(s) do I need to set to ensure the HTML generated for numbered equations has a width set?

The problem I am running into is that the HTML generated by MathJax is within a DOM element that tries to adjust its size to the content. This works perfectly as long as equations are not numbered. When they are numbered it seems the width of the components (the equation, and the equation number) is zero, so they are displayed overlapping and the parent element can't set its size correctly.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

ael...@yahoo.co.uk

unread,
Mar 30, 2013, 12:39:37 PM3/30/13
to mathja...@googlegroups.com
Sadly no, but it is enough to put e.g. "\begin{align}\sin{x}&=0\end{align}" inside a DIV which has the CSS "width: fit-content;" (possibly -moz-fit-content on older FF versions), together with equationNumbers: {autoNumber: "AMS"} in the MathJax config.

Peter Krautzberger

unread,
Mar 30, 2013, 2:04:37 PM3/30/13
to mathja...@googlegroups.com
Sorry, I can't reproduce this. Please create a minimal live example using something like jsfiddle or simply in a public dropbox folder. If it only happens on certain browsers (and versions), let us know. It could be anything from CSS interaction to timing issues.

Peter.

ael...@yahoo.co.uk

unread,
Mar 31, 2013, 11:31:07 AM3/31/13
to mathja...@googlegroups.com
Sorry, I didn't realize that MathJax would work well from jsfiddle! Thanks for the tip.

Here's a working example (for Firefox) demonstrating the problem:
http://jsfiddle.net/8Wnxk/21/

It's not clear to me what is determining the width value of the various MathJax-generated elements.

I should also have checked the documentation for fit-content (https://developer.mozilla.org/en-US/docs/CSS/width). This special value has not been unprefixed yet, though it exists in prefixed form for both mozilla (gecko versions >= 1.9) and Chrome (v >= 22).

ael...@yahoo.co.uk

unread,
Mar 31, 2013, 11:43:18 AM3/31/13
to mathja...@googlegroups.com, ael...@yahoo.co.uk
>It's not clear to me what is determining the width value of the various MathJax-generated elements.

Actually, thanks to jsfiddle, it is easy to see that the width as seen by *-content simply does not take account of the floating equation number.
http://jsfiddle.net/8Wnxk/29/

ael...@yahoo.co.uk

unread,
Apr 2, 2013, 9:26:00 AM4/2/13
to mathja...@googlegroups.com, ael...@yahoo.co.uk

Peter Krautzberger

unread,
Apr 3, 2013, 12:00:49 PM4/3/13
to mathja...@googlegroups.com, ael...@yahoo.co.uk
Thanks for this! I see what you mean now. This looks like a bug so I've created an issue on our bug tracker.


On Tue, Apr 2, 2013 at 6:26 AM, <ael...@yahoo.co.uk> wrote:

Frédéric WANG

unread,
Apr 4, 2013, 5:17:24 AM4/4/13
to mathja...@googlegroups.com
I attach a testcase that gather the problems with MathJax and intrinsic
widths.

--
Fr�d�ric Wang
maths-informatique-jeux.com/blog/frederic

testcase-intrinsic-width.html

Davide P. Cervone

unread,
Apr 4, 2013, 9:16:36 AM4/4/13
to mathja...@googlegroups.com
I have made the following comment on the issue tracker, but repeat it here:

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.



On Apr 4, 2013, at 5:17 AM, Frédéric WANG wrote:

I attach a testcase that gather the problems with MathJax and intrinsic widths.

--


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


<testcase-intrinsic-width.html>

ael...@yahoo.co.uk

unread,
Apr 5, 2013, 8:00:33 AM4/5/13
to mathja...@googlegroups.com
 Thanks for investigating this!
Reply all
Reply to author
Forward
0 new messages