KaTeX: Error with subscript or superscript

Typing \log_{10}\left(x\right) into the preview at katex.org results in the error Invalid markup: Incorrect number of children for <msub/> tag. Same with \log^{10}\left(x\right)

I am using Firefox 63.0.3 on Windows. The error does not occur on Chrome or Edge.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

With that instruction, I can reproduce the error. It seems to happen with \log_5 x but not \log x.

Ah, I see the issue now. <msub> is supposed to have only two children, but in this example, it has 3. This is caused by op’s MathML builder returning a document fragment: https://github.com/KaTeX/KaTeX/blob/f71f469d4b3ca97654702a0807e736d176f4c4c5/src/functions/op.js#L251-L263

I think we need to modify supsub’s MathML builder to wrap a fragment in an mrow, in this line: https://github.com/KaTeX/KaTeX/blob/f71f469d4b3ca97654702a0807e736d176f4c4c5/src/functions/supsub.js#L204

Alternatively, we need to bring the &ApplyFunction; outside of the subscript…

The error shows up if you select CSS under filter output in the console. Is this an issue?