I am building documentation using Sphinx. I have the following in a rst file:
.. math::
{{a^{{p_1}{p_2}}_{{p_3}{p_4}}}{a^{␣\,{p_5}}_{{p_6}{p_7}}}}
While building, this produces "Math input error". It works if I remove the ␣
.
Any ideas on how to fix this?
In conf.py
:
extensions = [
'sphinx.ext.mathjax',
]
Sphinx version: 7.1.2, Python version: 3.8.19
This is the expected output:
The issue is fixed in v4 (now out in beta release). But for v3, you could try using \unicode{x2423}
instead of the explicit unicode character, as that should avoid the error.
If you must use the exploit unicode character, you could use the following MathJax configuration to patch the problem:
MathJax = {
tex: {
packages: {'[+]': ['fix-unicode']}
},
startup: {
ready() {
const {Configuration} = MathJax._.input.tex.Configuration;
const {MapHandler} = MathJax._.input.tex.MapHandler;
const NodeUtil = MathJax._.input.tex.NodeUtil.default;
const {getRange} = MathJax._.core.MmlTree.OperatorDictionary;
function Other(parser, char) {
const font = parser.stack.env['font'];
let def = font ? {mathvariant: parser.stack.env['font']} : {};
const remap = (MapHandler.getMap('remap')).lookup(char);
const range = getRange(char);
const type = range?.[3] || 'mo';
let mo = parser.create('token', type, def, (remap ? remap.char : char));
range?.[4] && mo.attributes.set('mathvariant', range[4]);
if (type === 'mo') {
NodeUtil.setProperty(mo, 'fixStretchy', true);
parser.configuration.addNode('fixStretchy', mo);
}
parser.Push(mo);
}
Configuration.create('fix-unicode', {fallback: {character: Other}});
MathJax.startup.defaultReady();
}
}
};