Line Breaking in MathJax

470 views
Skip to first unread message

Amine Marref

unread,
Feb 10, 2021, 12:49:48 PM2/10/21
to MathJax Users
Hello,

I have a question on line breaking in MathJax. I am attaching a figure that shows a side-by-side visual comparison between MathJax-rendered equations in versions 2.7.9 and 3.1.2 respectively.

The figure shows 4 rendered equations of the form f'(x)=rational function. In the left (v 2.7.9), we can see that the rendering algorithm decided to put f'(x) in different places in the two equations. In the right (v 3.1.2), we can see that the rendering algorithm decided to be a little bit more consistent.

My first question is: how do I instruct the rendering process in v 2.7.9 to display my equations in a consistent way?

My second question is: if it is possible to instruct the rendering to be consistent, how would I force the rendering to be the one in the equation marked with a green asterisk?

Many thanks.

For reference, the following is the configuration bit for the line-breaking.
<!-- LINE BREAKING CONFIGURATION FOR VERSION 3.1.2 -->
<script type="text/x-mathjax-config">                
        MathJax.Hub.Config({
                "HTML-CSS": { linebreaks: { automatic: true } },
                SVG: { linebreaks: { automatic: true } }
         });
</script>
 <!-- LINE BREAKING CONFIGURATION FOR VERSION 2.7.9 -->     
<script type="text/x-mathjax-config">
            MathJax.Hub.Config({
            CommonHTML: { linebreaks: { automatic: true } },
            "HTML-CSS": { linebreaks: { automatic: true } },
                    SVG: { linebreaks: { automatic: true } }
            });
</script>


line-breaking-issues.png

Davide Cervone

unread,
Feb 13, 2021, 2:50:02 PM2/13/21
to mathja...@googlegroups.com
There are a couple of things to say, here.  First, what you claim to be your v3 configuration is actually a v2 configuration and will not affect version 3 in any way.  Version 3 does not have MathJax.Hub, and does not have the HTML-CSS output renderer (only the CommonHTML one).  MathJax version 3 is configured in a different way, see


and the configuration conversion tool at


so this v2 configuration will be completely ignored by version 3.

Second, version 3 does not yet implement the line breaking algorithm, see


so the breaking your re seeing is not due to MathJax.  Since the math should not be broken, I can only assume that some CSS on the page is overriding MathJax's CSS to allow the browser to insert line breaks where MathJax would have prevented it.  I can't tell without seeing the page.  In any event, the line breaking is not being done by Mathjax, and that would account for the poor layout.

Finally, automatic line breaking within fractions is done to the full width of the available content, not to the space "left over" from other content.  This is a last-ditch effort to get your content displayed, so can lead to sub-optimal layout, as in your second example.  your first example only works well because the various terms have sufficient nesting to prevent internal line breaks, so there is enough left-over space for the function and equal sign; the second has longer terms, so there is no space left over.  You can force line breaks in your fractions at better location, or could implement TeX macros that help control the breaking, as described in this post


There is more detail about how the line breaking works at


though this is a discussion about MathML rather than TeX input.  In any case, the fact that fractions break to the full width of the container is not something you can change.

Davide

Amine Marref

unread,
Feb 17, 2021, 3:53:23 AM2/17/21
to mathja...@googlegroups.com
Thanks a lot for the clarification :-)

--
You received this message because you are subscribed to a topic in the Google Groups "MathJax Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mathjax-users/7dw-G3L74ck/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/E1897119-0F2F-4D69-9C53-1C51A1B6FB3A%40gmail.com.


--
Reply all
Reply to author
Forward
0 new messages