fast-reflexes / better-react-mathjax

MIT License
124 stars 16 forks source link

Some type cant display correctly #58

Closed majiayu000 closed 5 months ago

majiayu000 commented 5 months ago

Some latex like $12 - \frac{7}{11}$.

If put this in mathjax, this can display, but cant here. image image

fast-reflexes commented 5 months ago

I think you're just forgetting about escape characters in Javascript strings. When you want to output a \ you have to add \\ inside a string.

majiayu000 commented 5 months ago

image Seems not a \ question.

fast-reflexes commented 5 months ago

Have you added $ as a delimiter in your config? At least you're no longer getting Math input error so you also had a problem with escaping it seems. $ is not a default MathJax delimiter so you have to specify it. Try using $$. If that works, then you need to specify $ as a delimiter as well.

majiayu000 commented 5 months ago

Thanks for your patients. After I using config, it worked. I did not see these configs.

fast-reflexes commented 5 months ago

No problem :) Feel free to close this ticket if the problem is solved :)

majiayu000 commented 5 months ago

\frac{1}{2} I meet another question. How can just display a latex without any \\ or (.

Thank you!

fast-reflexes commented 5 months ago

You can't. MathJax operates on delimiters. You can use manual typesetting and provide the string you want to typeset like

          <MathJax
            renderMode={"pre"}
            typesettingOptions={{ fn: "tex2chtml" }}
            text={`x^4 = 100`}
          />

but I wouldn't recommend that.

majiayu000 commented 5 months ago

Ok, so the question is to discover the latex string. I will try, thank you again!