-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
v4-beta.3 linebreak not respected with \text
(and other issues)
#3098
Comments
\text
(and other issues)
I believe you need to load the textmacros extension to get |
While true, none of the example use |
MathJax's rules for breaking in-line math are based on the TeX rules for in-line breaks, which are basically that breaks can occur at characters that have class BIN or REL (binary operators and relations) at the top level of the expression. Your first example has no binary or relational operator (the Your second example, with the Your third and fourth examples that use In your expression <math xmlns="http://www.w3.org/1998/Math/MathML">
<mtext mathvariant="monospace">Maybe (Either (a, a) (Bool, a))</mtext>
<mspace linebreak="newline"></mspace>
<mo>≡</mo>
<mtext mathvariant="monospace">(Maybe a, Maybe a)</mtext>
</math> Note that this consists of an operator (the equivalent sign) together with This is the same issue for your case that involves the equal sign as well. Ironically, it is also the case for the long text example at the bottom of your supporting demo page. There is one operator in that expression (the period), and the rest are text elements, so the entire sentence is an embellished operator, and treated as a single (unbreakable) unit, so no line-breaking occurs. This illustrates why I find the idea that One way around the problem is to add any non-text, non-space element into the expression. For example, adding {}\texttt{Maybe (Either (a, a) (Bool, a))} \break \equiv \texttt{(Maybe a, Maybe a)} would make the operator no longer be an embellished one, and so line breaking would occur as expected. The same goes for the long expression in your demo (or you could put the period inside one of the preceding Alternatively, you could adjust how MathJax interprets "spacelike" to make MathJax = {
startup: {
ready() {
const {MML} = MathJax._.core.MmlTree.MML;
MML.mspace = class myMmlMspace extends MML.mspace {
get isSpacelike() {
return this.attributes.getExplicit('linebreak') === undefined && this.canBreak;
}
}
MML.mtext = class myMmlMtext extends MML.mtext {
get isSpacelike() {
const attributes = this.attributes;
const spaces = !!this.getText().match(/^\s*$/);
return spaces && (attributes.getExplicit('mathbackground') === undefined &&
attributes.getExplicit('background') === undefined &&
attributes.getExplicit('style') === undefined);
}
}
MathJax.startup.defaultReady();
}
}
}; into your MathJax configuration. Then the expression you have used should break as you would expect. |
I forgot to mention the error messages you received. That is due to having switched to CHTML output using the contextual menu. It turns out that the way exports are handled in ESM modules is causing a problem loading the |
Finally, it would help us if you only include one type of problem in one issue post. Your line-break issues could all be in one, but the problem with the expression involving the |
Thanks for the comprehensive explanation! After some testing, placing \texttt{Maybe (Either (a, a) (Bool, a))} {} \break \equiv \texttt{(Maybe a, Maybe a)} Another thing I forgot to mention was automatic linebreaking (i.e. without P.S. Apologies for not testing my |
It shouldn't matter where the Note that it should only matter when there is only one operator in the expression. If you have |
Prevent setting a propery that has a getter. (mathjax/MathJax#3098)
Update check for spacelike mml nodes to be more sensible. (mathjax/MathJax#3098)
Issue Summary
Linebreak issue with text elements.
Steps to Reproduce:
Linebreak not working with text. Math is a bit better, but also sticks out a bit.
For example:
There are also instances when output errors occur for regular LaTeX and for
\break
s.All of these are shown in the supporting demo.
Technical details:
I am using the following MathJax configuration:
and loading MathJax via
Supporting information:
.post-body
container.The text was updated successfully, but these errors were encountered: