Open vivek-shadija opened 3 months ago
First, you have filed this issue in the wrong place. As the issue template indicates, this issue tracker is only for structural problems with the source code repository, not for general MathJax issues, which should be filed here. Don't just erase the information given in the issue template and ignore it.
I am transferring this issue to the proper issue tracker.
Not every LaTeX command is implemented in MathJax, and none of these is. You can find a list of the commands that are available in the documentation. You don't indicate which version of MathJax you are using, so I've pointed to the v3 documentation.
For \parallelogram
you could use \unicode{x25B1}
, and could do \newcommand{\parallelogram}{\unicode{0x25B1}}
to define \parallelogram
to produce that.
For \overarc
perhaps the best substitute is \overparen
, and you can do \let\overarc=\overparen
to define \overarc
to produce that.
For \questeq
you could use \stackrel{?}{=}
and could do \newcommand{\questeq}{\stackrel{?}{=}}
to define \questeq
to equal that.
These three could be added to your MathJax configuration as described in the documentation.
The \longdiv
macro is more challenging. If you are looking for \longdiv{num}{den}
where num
and den
are integers, then there is an old v2 implementation here. For v4, I worked up a configuration that implements it:
MathJax = {
tex: {
packages: {'[+]': ['longdiv']}
},
startup: {
ready() {
const {Configuration} = MathJax._.input.tex.Configuration;
const {CommandMap} = MathJax._.input.tex.TokenMap;
const TexError = MathJax._.input.tex.TexError.default;
const TexParser = MathJax._.input.tex.TexParser.default;
new CommandMap('longdiv', {
longdiv: 'LongDiv'
}, {
LongDiv(parser, name) {
const num = parser.GetArgument(name);
const den = parser.GetArgument(name);
if (!num.match(/^\d+$/) || !den.match(/^\d+/)) {
throw new TexError('LONGDIV:NumDen', 'Numerator and denominator of %1 must be positive integers', name);
}
const n = parseInt(num);
const d = parseInt(den);
const q = Math.floor(n / d);
let m = n;
const tex = [
'\\begin{array}[t]{r}',
`${q} \\kern.2em \\\\[-3px]`,
`${d}\\kern.1em \\enclose{longdiv}{\\kern.075em ${n}} \\\\[-4px]`
];
const digits = String(q).split('');
while (digits.length) {
const digit = parseInt(digits.shift() + digits.join('').replace(/./g, '0'));
if (digit === 0) continue;
const p = d * digit;
m -= p;
tex.push(
`\\underline{\\kern .2em ${p}\\Space{.2em}{0em}{.125em}} \\\\[-3px]`,
`${m}\\Space{.2em}{0em}{.125em} \\\\[-4px]`
);
}
tex.push('\\end{array}');
parser.Push(new TexParser(tex.join('\n'), parser.stack.env, parser.configuration).mml());
}
});
Configuration.create('longdiv', {
handler: {
macro: ['longdiv']
}
});
MathJax.startup.defaultReady();
}
}
};
If you are using v3, this should also work there, with one change: TokenMap
should be changed to SymbolMap
in the second line of the ready()
function.
Issue: Below mentioned 4 math commands are not recognized by mathjax and they are not rendered.