MathJax
MathJax copied to clipboard
\def commands containing numbers
Issue Summary
The error occurs when using \def to define a command containing numbers, for example
\def\b0{{\bf0}}
Steps to Reproduce:
In MathJax:

In LaTeX :

Technical details:
- MathJax Version: 3.2
- Client OS: Windows 11
- Browser: Firefox
Note that TeX control sequences can't contain numbers, so what you are actually doing is defining \b with a template that requires it to be followed by 0. It looks like there is a bug with macros that have templates but no arguments. I will look into it.
I have submitted a pull request that resolves the problem, and it should be in the next release. In the meantime, you can use the configuration
MathJax = {
startup: {
ready() {
const TexError = MathJax._.input.tex.TexError.default;
const ParseUtil = MathJax._.input.tex.ParseUtil.default;
const NewcommandUtil = MathJax._.input.tex.newcommand.NewcommandUtil.default;
const NewcommandMethods = MathJax._.input.tex.newcommand.NewcommandMethods.default;
const MacroWithTemplate = NewcommandMethods.MacroWithTemplate;
NewcommandMethods.MacroWithTemplate = function (parser, name, text, n, ...params) {
const argCount = parseInt(n);
if (argcount || !params.length) {
MacroWithTemplate(parser, name, text, n, ...params);
} else {
parser.GetNext();
if (params[0] && !NewcommandUtil.MatchParam(parser, params[0])) {
throw new TexError('MismatchUseDef', 'Use of %1 doesn\'t match its definition', name);
}
parser.string = ParseUtil.addArgs(parser, text, parser.string.slice(parser.i));
parser.i = 0;
ParseUtil.checkMaxMacros(parser);
}
}
MathJax.startup.defaultReady();
}
}
};
to work around the problem.