Katex does not parse but MathJax does
See original GitHub issueSo we have an equation with _ (underscores) in the name like:
\text{Score} = 2\times\text{(Protein_(g))} - 0.75\times\text{(Lipid_Tot_(g))}
And in mathjax it renders it just fine (url). However as seen if one uses https://khan.github.io/KaTeX/, Katex yields this error:
KaTeX parse error: Expected '}', got '_' at position 37: …s\text{(Protein_̲(g))} - 0.75\…
Do we know why, and if so should we fix Katex or is mathjax wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Common Issues - KaTeX
KaTeX does not support the align environment because LaTeX doesn't support align in math mode. The aligned environment offers the same functionality but...
Read more >MathJax and KaTeX working in HTML but not ... - Stack Overflow
But when I try the following code in Javascript it doesn't work: document.getElementById("output").innerHTML = "$$ \int f(x)dx $$". Why is ...
Read more >Syntax Extensions - MyST-Parser
Math is parsed by adding to the myst_enable_extensions list option, ... be parsed if there are no initial / final spaces, e.g. $a$...
Read more >MathJax Frequently Asked Questions
Mathematics is not rendering properly in IE. How do I fix that?¶ ... First, please open the MathJax homepage at www.mathjax.org in IE...
Read more >katex - npm
Make sure to include the CSS and font files, but there is no need to include the JavaScript. Like render , renderToString throws...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@pkra thanks linking to the relevant MathJax issue. I’m glad to hear that you’re considering making this configurable in v3. In the interest of improving interoperability KaTeX could add the current MathJax behaviour and make it configurable as well. For KaTeX though, I think we’d probably want to make our current behaviour the default. The rationale being that there’s probably more TeX code in the world that relies on the TeX behaviour than than the current MathJax behaviour.
A relevant issue would be https://github.com/mathjax/mathjax-v3/issues/135.
Before going all xkcd#386, you might consider that are valid reasons to avoid text mode (e.g., it is essentially a different layout system, also incompatible with CSS). Some are mentioned at https://docs.mathjax.org/en/latest/tex.html#differences.
If you are interested in thinking about the larger community, you might consider starting a discussion on the W3C MathOnWeb community group to work towards better compatibility across TeX-like conversion tools. (Disclaimer: I co-chair the CG.)