Erroneous MathJax subscript rendering in LaTeX blocks in GitHub repos #36984
Replies: 2 comments 1 reply
-
Hi there @dead-claudia and welcome to our community 😄. Thanks so much for asking a great question! |
Beta Was this translation helpful? Give feedback.
-
The GitHub implementation of MathJax has a number of problems. Because LaTeX notation doesn't mesh well with Markdown notation, they have tried to handle that by quoting the LaTeX characters in ways that would prevent them from being processed by Markdown. Unfortunately, they haven't gotten in right, and there are a number of situations that they have not handled properly. One of them is underscores, which Markdown uses to indicate italics. So when you type
you get $\mathtt{a}\text{s} ~ \mathtt{b}\text{t}$ Note that the text between the underscores is in italics and the underscores are missing, which means Markdown has replaced the underscores with HTML tags that indicate italics. MathJax doesn't process math that includes HTML tags, so that prevents MathJax from typesetting the result. Your example seems to not have the underscores at all, so it may be that when an item is posted, the processing is different (I will find out shortly when this is posted), but in the preview the math is not typeset due to the HTML tags for italic. You should be able to get it to work using
though if they ever fix this problem, your equations will end up with actual underscores in the output, like |
Beta Was this translation helpful? Give feedback.
-
OK: (
\mathtt{a}_\text{s}
)Broken: (
\mathtt{a}_\text{s} ~ \mathtt{b}_\text{t}
)$$
\mathtt{a}\text{s} ~ \mathtt{b}\text{t}
$$
Screenshot as rendered in my browser (dark mode, but that should be irrelevant):
![image](https://user-images.githubusercontent.com/4483844/197360659-1b8e8cb6-a5d3-4ddc-a1f0-5ad46daabb62.png)
Expected (light mode):
![image](https://user-images.githubusercontent.com/4483844/197360923-72784212-d5df-4582-9c7d-8c1f9196e30e.png)
I can confirm this 100% of the time here in this discussion post as well as in general repo files, but I can't confirm it with the MathJax version you all are using (3.2.0) in isolation, so there's something you all are doing that is causing it to mess up. (I figured that out by simply running
MathJax.version
in the web console.)Someone else ran into similar and reported it (incorrectly) against MathJax directly (mathjax/MathJax#2953), and their source text (
\hat{A}{1,2} = B{1,2}
) also has similar rendering issues.Beta Was this translation helpful? Give feedback.
All reactions