-
-
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
Erroneous "Erroneous nesting of equation structures" #3070
Comments
OK, thanks for the report. I will need to look into it. The logic for handling the nesting of AMS structures has been changed (see the last paragraph of the New TeX Features in the release notes), and obviously something went wrong. |
OK, I found it. There is a bug in where mathjax/MathJax-src@7bb5fbd#diff-8b54d4a07ba56e1e6678245687ace65d468dd87cb4c8770a11b261c94d0231a0 as you can see by the first difference line above. In any case, the following configuration will fix the error: MathJax = {
tex: {
packages: {'[+]': ['fix-equation']}
},
startup: {
ready() {
const {Configuration} = MathJax._.input.tex.Configuration;
const {EnvironmentMap} = MathJax._.input.tex.SymbolMap;
const {environment} = MathJax._.input.tex.ParseMethods.default;
const ParseUtil = MathJax._.input.tex.ParseUtil.default;
new EnvironmentMap('fix-equation', environment, {
displaymath: ['Equation', null, false],
math: ['Equation', null, false, false],
equation: ['Equation', null, true],
`equation*`: ['Equation', null, false],
}, {
Equation(parser, begin, numbered, display = true) {
parser.configuration.mathItem.display = display;
parser.stack.env.display = display;
ParseUtil.checkEqnEnv(parser);
parser.Push(begin);
return parser.itemFactory.create('equation', numbered).
setProperty('name', begin.getName());
}
});
Configuration.create('fix-equation', {
handler: {environment: ['fix-equation']}
});
MathJax.startup.defaultReady();
}
}
}; Merge this into your current configuration (e.g., move the Thanks for trying out beta.3 and reporting the problem. |
The same test page with the indicated fix: https://cdi2.palhoto.pt/test_5 Everything works! Thanks for your incredible work with MathJax. |
Glad it is working for you now. Thanks for letting us know. |
@dpvc Thank you for the fix. However, while it works for most environments, it doesn't seem to resolve the issue for Example: <html>
<head>
<script>
MathJax = {
tex: {
packages: {'[+]': ['fix-equation']}
},
startup: {
ready() {
const {Configuration} = MathJax._.input.tex.Configuration;
const {EnvironmentMap} = MathJax._.input.tex.SymbolMap;
const {environment} = MathJax._.input.tex.ParseMethods.default;
const ParseUtil = MathJax._.input.tex.ParseUtil.default;
new EnvironmentMap('fix-equation', environment, {
displaymath: ['Equation', null, false],
math: ['Equation', null, false, false],
equation: ['Equation', null, true]
}, {
Equation(parser, begin, numbered, display = true) {
parser.configuration.mathItem.display = display;
parser.stack.env.display = display;
ParseUtil.checkEqnEnv(parser);
parser.Push(begin);
return parser.itemFactory.create('equation', numbered).
setProperty('name', begin.getName());
}
});
Configuration.create('fix-equation', {
handler: {environment: ['fix-equation']}
});
MathJax.startup.defaultReady();
}
}
};
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/tex-mml-chtml.js">
</script>
</head>
<body>
This works:
\begin{equation}
A=B
\end{equation}
As does this:
\[
A=B
\]
But not this:
\begin{equation*}
A=B
\end{equation*}
</body>
</html> This renders as follows (in several major browsers): (I don't know JS. Have I implemented your fix incorrectly?) |
OK, sorry, I missed 'equation*': ['Equation', null, false] after the corresponding definition for |
Thanks for your suggestion. However, should |
Yes. Sorry about that.
That suggests you made an error in the configuration and the configuration isn't being processed or is processed in correctly. Here is the full configuration from my example MathJax = {
tex: {
packages: {'[+]': ['fix-equation']}
},
startup: {
ready() {
const {Configuration} = MathJax._.input.tex.Configuration;
const {EnvironmentMap} = MathJax._.input.tex.SymbolMap;
const {environment} = MathJax._.input.tex.ParseMethods.default;
const ParseUtil = MathJax._.input.tex.ParseUtil.default;
new EnvironmentMap('fix-equation', environment, {
displaymath: ['Equation', null, false],
math: ['Equation', null, false, false],
equation: ['Equation', null, true],
'equation*': ['Equation', null, false]
}, {
Equation(parser, begin, numbered, display = true) {
parser.configuration.mathItem.display = display;
parser.stack.env.display = display;
ParseUtil.checkEqnEnv(parser);
parser.Push(begin);
return parser.itemFactory.create('equation', numbered).
setProperty('name', begin.getName());
}
});
Configuration.create('fix-equation', {
handler: {environment: ['fix-equation']}
});
MathJax.startup.defaultReady();
}
}
}; This works for me in my test program. I've edited the previous example as well, so others who find this will get the correct behavior from either example. |
That works now for me, too. Thank you! |
Fix incorrect flagging of nested environments. (mathjax/MathJax#3070)
I believe I have found some error in the "Erroneous nesting of equation structures" flagging when using \begin{equation}\end{equation}
Version
MathJax Version:4.0.0-beta.3
I am loading MathJax locally and the configuration is identical to what I had for version 4.0.0-alpha.1, namely
window.MathJax = {
output: {
font: 'mathjax-fira',
linebreaks: {// options for when overflow is linebreak
inline: true, // true for browser-based breaking of inline equations
width: '100%', // a fixed size or a percentage of the container width
lineleading: .2, // the default lineleading in em units
LinebreakVisitor: null // The LinebreakVisitor to use
}
},
loader: {load: ['ui/lazy']},
svg: {
scale: 1,
mtextInheritFont: true,
displayOverflow: "linebreak",
matchFontHeight: false
},
chtml: {
scale: 1,
mtextInheritFont: true,
displayOverflow: "linebreak"
},
options: {
processHtmlClass: "math",
ignoreHtmlClass: "tex2jax_ignore"
},
tex: {
tags: 'ams',
macros: {
sen: "\operatorname{sen}",
tg: "\operatorname{tg}",
arctg: "\operatorname{arctg}",
arcsen: "\operatorname{arcsen}",
arcos: "\operatorname{arcos}",
div: "\operatorname{div}",
rot: "\operatorname{rot}"
},
inlineMath: [['$', '$'], ['\(', '\)']],
displayMath: [['$$', '$$'], ["\[", "\]"]],
processEscapes: true,
autoload: {
color: ['color']
}
}
/* tex: {
packages: {'[+]': ['noerrors', 'action']}
},
loader: {
load: ['[tex]/noerrors', '[tex]/action']
} */
};
Example page:
https://cdi2.palhoto.pt/test
The text was updated successfully, but these errors were encountered: