Reputation: 16845
I have a problem with my blog. When writing posts I can also add math using MathJax. I also have a little markup language of mine where I can handle italic and bold text. It happens that the syntax for italic collides with the MathJax one's for subscript.
So, if I write in a port the following:
My cat was doing this strange sound: _Prrrrrr_.
The text between underscores is redered with a span tag using italic style.
But in MathJax using underscores means having subscripts. Sometimes I have problems of course. The point is that first my markup language is handled, then Mathjax can run.
Is there a way to tell MathJax to make subscripts and superscripts without using underscores but an alternative syntax?
Thankyou
Upvotes: 4
Views: 805
Reputation: 7463
I found escaping the underscores with a backslash helped, like this:
...strange sound: \_Prrrrrr\_.
But this did cause some parsers to render things incorrectly.
However, if you also define '\_
' as a macro which just outputs '_
', then it all seems to work.
To do this in MathJax:
MathJax.Hub.Config({TeX: {Macros: { '\_': ['_'] }}, /* rest of config here... */ });
To do this in Katex, I changed katex_config.js
to:
module.exports = {
macros: { '\\_': '_' }
}
Upvotes: 1
Reputation: 16845
There is a way. Using Macros as described here: Configure Tex in MathJax. By setting something like this:
MathJax.Hub.Config({TeX: {Macros:{subscript:['_{#1}',1],superscript:['^{#1}',1]}}});
The system (MathJax) will substitute this stuff with the underscore and then parse it, my problem is actually solved like this!
Upvotes: 1