-
-
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
MathJax V2 vs V3 rendering #3095
Comments
Here's what's happening. By default, MathJax uses TeX spacing rules rather than MathML spacing rules, and TeX determines spacing by applying one of eight TeX classes to every item in the expression, and uses the pair of classed to determine the spacing between adjacent items. When MathJax processes an In version 2 of MathJax, there was an exception made to the rule for In the meantime, there are several possible approaches you could take. First, you could configure MathJax's output to use MathML spacing rather than TeX spacing, which would include space around any operator that is not in the dictionary. Another possibility would be to change Another possibility would be to add Finally, you could use the following configuration to patch to add the special rule for multi-letter operators. MathJax = {
startup: {
ready() {
const {mo} = MathJax._.core.MmlTree.MML.MML;
const {getRange} = MathJax._.core.MmlTree.OperatorDictionary;
const {TEXCLASS} = MathJax._.core.MmlTree.MmlNode;
mo.prototype.checkOperatorTable = function (mo) {
let [form1, form2, form3] = this.handleExplicitForm(this.getForms());
this.attributes.setInherited('form', form1);
let OPTABLE = this.constructor.OPTABLE;
let def = OPTABLE[form1][mo] || OPTABLE[form2][mo] || OPTABLE[form3][mo];
let noTexClass = this.getProperty('texClass') === undefined;
if (def) {
if (noTexClass) {
this.texClass = def[2];
}
for (const name of Object.keys(def[3] || {})) {
this.attributes.setInherited(name, def[3][name]);
}
this.lspace = (def[0] + 1) / 18;
this.rspace = (def[1] + 1) / 18;
} else {
let limits = this.attributes.get('movablelimits');
let isOP = !!mo.match(/^[a-zA-Z]{2,}$/);
let range = getRange(mo);
if (range) {
if (noTexClass) {
this.texClass = (isOP && range[2] === TEXCLASS.REL) || limits ? TEXCLASS.OP : range[2];
}
const spacing = this.constructor.MMLSPACING[range[2]];
this.lspace = (spacing[0] + 1) / 18;
this.rspace = (spacing[1] + 1) / 18;
} else if (noTexClass) {
this.texClass = isOP || limits ? TEXCLASS.OP : TEXCLASS.REL;
}
}
};
MathJax.startup.defaultReady();
}
}
}; I think that will improve the situation for you. You might also want to add |
Hi Thank You for providing the in-depth details. I have a couple of points to ask for the above solutions provided.
Best, |
Hi Team, Could you please update us on the queries posted above? Best, |
We respond to questions when we are able to, and that sometimes takes time. Your message is still in my queue, and I haven't forgotten about you, but have not had time to respond. Poking me about it doesn't speed things up. In fact, it often makes it take longer, as I have to deal with extra messages and respond to them, like now.
You say that there was no effect, but did you clear the browser cache before trying? It may be that you have the original mathjax.config.js file in cache and aren't getting the new one. Try adding a console.log() message in the checkOperatorTable() function and make sure that it is actually being called. If not, add one in the top of the ready() function and make sure THAT is being called. If not, you may need to provide more than just a snippet of the configuration.
|
Set TeX class OP for multi-letter mo elements, as in v2. (mathjax/MathJax#3095)
Hi, Just to confirm that we are able to view the updated code and even after clearing the browser cache, we are not able to view the updates we are expecting. As suggested please find the attached mathjax-config file under which I have added the provided solution. Please review and let us know if it still requires more changes to incorporate the changes we are looking for. Also, suggest a way to add words to the dictionary with TeX class OP, and how do we configure MathJax's output to use MathML? is there any specific property we need to add to the mathjax-config.js? Best, |
Hi Team, Thank You for replying back on the queries we have raised so far. As we are still not able to resolve the issue as per the output we are expecting here are some more pointers to be addressed: First, I would like to get a confirmation on 1 point from the above example -> "http://www.w3.org/1998/Math/MathML" Also, we want to execute the conversion as soon as the mathJax is initialized, so we have kept document.mathInputProcessed(); under mathjax-config.js as startup: { ready: function() {document.mathInputProcessed();} } - The original file was shared earlier. We also added the patch provided by you and wrote console.log() along with it to see if the code is updated and not cached, but the patch is not working as expected even code was updated. Another point, In the very first comment you mentioned: you could configure MathJax's output to use MathML spacing rather than TeX spacing, which would include space around any operator that is not in the dictionary. - how do we configure and check we are using MathML spacing instead of TeX spacing? Note: we are looking for a solution that can be implemented from the code side and not from the content (as making any change in the content is not possible for us) Best, |
You didn't respond to whether my test file above (in the October 12th comment) works for you. Does that work or not? The configuration that changes the
Both MathJax v2 and v3 are based on the MathML v3 specification, not MathML v2.
Yes, I indicated above why that is the case, and it is a bug in v3. I have made a fix for it that will be included in the next release, and gave you a patch (Aug 27th) that should resolve it for you. I have tested the patch, and it works for me. If that is not working for you, then you need to provide a complete page that illustrated the problem you are having, as there is something that you are doing differently from me. Saying it doesn't work without giving me what you are actually doing (not just the configuration, but the rest of the code that interacts with MathJax) gives me nothing to go on. I used your
MathJax may be initialized before the page is ready to be processed. That is, the Note also that MathJax will typeset the page automatically as soon as it can, unless to set I'm assuming that
It is not clear from your comment whether that console log was performed or not: "the patch is not working as expected" could mean that log message didn't appear, or it could mean that it did but that your output still was not what you wanted. Can you clarify that?
As described in the documentation, you should combine MathJax = {
chtml: {
mathmlSpacing: true;
},
svg: {
mathmlSpacing: true;
}
}; into you configuration to have MathJax use MathML spacing rules rather than TeX spacing rules. You can test this by using <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>x</mi>
<mo>+</mo>
<mo>=</mo>
<mo>-</mo>
<mi>y</mi>
</math> and compare the output to when you don't have and without it (or with
Note that MathJax allows you to add pre-filters that can be used to modify the MathML before MathJax processes it, so if there is problematic MathML in your original source files, it may still be possible to fix it on the fly as MathJax typesets it. For example, I had suggested adding
to your configuration will accomplish that. |
Hi,
We have identified a difference in the output of the MathML tags with v2 and v3 for the same equation.
With v2:
With v3:
Issue: There is a space after i(superscript), G(subscript), and C(subscript) in v2, whereas in v3 the space has been removed.
MathML Equation:
Is there any reason for the difference that has been observed?
Thanks,
Saksham Gambhir
The text was updated successfully, but these errors were encountered: