Open leberman opened 6 months ago
Update: this worked with version 2.7.8
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"auto-collapse": {
disabled: false,
},
collapsible: {
disabled: false,
},
showMathMenu: false,
zoom: "None",
zscale: "100%",
texHints: true,
jax: ["input/MathML", "output/HTML-CSS"],
CommonHTML: {
scale: 90,
minScaleAdjust: 55,
mtextFontInherit: false,
linebreaks: {automatic: true}
},
Safe: {
sizeMin: .4,
sizeMax: 1.44
}
});
</script>
Note that your math items are in-line math items because the math
node does not have the display="block"
attribute, so display
defaults to inline
. The mstyle
with displaystyle="true"
means that the display style rules will be used in the rendering, but it is still considered an in-line expression.
MathJax v2 did not perform in-line breaking except in limited situations, so the line-breaking you show from v2 would likely have to have been for displayed equations, not in-line ones (the equation numbers also suggest that that is the case, as in-line expressions don't get equation numbers). So I suspect the examples you have used are not actually the same in both cases.
MathJax v4 does implement in-line breaking, but note that the rules for in-line breaking are based on the TeX in-line breaking rules, which only break an expression at a top-level operator that is of class BIN
or REL
(a binary operator or a relational operator). Such operators must be children of the top-level math
element (or of top-level mstyle
or semantics
elements) in order for a breakpoint to be allowed. In particular, content inside an explicit mrow
element will not have in-line breaks, just as TeX will not break at operators within braces. That is, in x + {y + z}
the only in-line breakpoint that can be made is at the first plus sign (the second is not valid as it is inside braces). Similarly,
<math>
<mi>x</mi>
<mo>+</mo>
<mrow>
<mi>y</mi>
<mo>+</mo>
<mi>z</mi>
</mrow>
</math>
has only one valid in-line breakpoint at the first plus sign, and the second plus is not a breakpoint as it is inside an explicit mrow
tag.
The expressions you point to in your screen shot all have explicit mrow
elements around the complete expression, and so that prevents any inline breaks in those expressions. For example, the first one is
<math id="mml367">
<mstyle displaystyle="true">
<mrow>
<mi>A</mi>
<mo>=</mo>
<mi>π</mi>
<msqrt>
<mn>1</mn>
<mi>a</mi>
</msqrt>
<mo>←</mo>
<mo>↑</mo>
<mo>→</mo>
<mo>↓</mo>
<mi>∞</mi>
<mo>≠</mo>
<mo>∝</mo>
<mo>≅</mo>
<mo>≈</mo>
<mo>≡</mo>
<mo>∀</mo>
<mo>∃</mo>
<mi>∅</mi>
<mo>∩</mo>
<mo>∪</mo>
<mo>∂</mo>
<mi>ρ</mi>
<mi>φ</mi>
<mi>γ</mi>
<mi>ς</mi>
<mo>⊂</mo>
<mo>⊃</mo>
<mo>⊕</mo>
<mo>⊝</mo>
<mo>⊗</mo>
<mi>σ</mi>
<mi>ω</mi>
<mo>∋</mo>
<mo>∈</mo>
<mo>∆</mo>
<mi>γ</mi>
<mi>ε</mi>
<mi>θ</mi>
<mi>τ</mi>
</mrow>
</mstyle>
</math>
which won't break, but if you remove the outer mrow
, as in
<math id="mml367">
<mstyle displaystyle="true">
<mi>A</mi>
<mo>=</mo>
<mi>π</mi>
<msqrt>
<mn>1</mn>
<mi>a</mi>
</msqrt>
<mo>←</mo>
<mo>↑</mo>
<mo>→</mo>
<mo>↓</mo>
<mi>∞</mi>
<mo>≠</mo>
<mo>∝</mo>
<mo>≅</mo>
<mo>≈</mo>
<mo>≡</mo>
<mo>∀</mo>
<mo>∃</mo>
<mi>∅</mi>
<mo>∩</mo>
<mo>∪</mo>
<mo>∂</mo>
<mi>ρ</mi>
<mi>φ</mi>
<mi>γ</mi>
<mi>ς</mi>
<mo>⊂</mo>
<mo>⊃</mo>
<mo>⊕</mo>
<mo>⊝</mo>
<mo>⊗</mo>
<mi>σ</mi>
<mi>ω</mi>
<mo>∋</mo>
<mo>∈</mo>
<mo>∆</mo>
<mi>γ</mi>
<mi>ε</mi>
<mi>θ</mi>
<mi>τ</mi>
</mstyle>
</math>
then line breaks are possible (try it in your codepen example).
The other expression also has mrow
elements that are preventing inline breaks, but you have to remove several of them in order to get the line breaks. I will leave that to you.
Note that line breaking of displayed equations is more general, and can break inside mrow
and other nested nodes. If you add display="block" indentalign="left"
to the long expression you provide in your first message, then you will get line breaking within that expression without having to remove the mrow
elements.
So the upshot is, this is the expected behavior for MathJax's line breaking.
I am using the latest version of MathJax But line breaking is not working.
I am using the following MathJax configuration:
and loading MathJax via
Implemented sample:
https://codepen.io/Mohammad-Shahbazi-the-styleful/pen/OJqGXmx