fast-reflexes / better-react-mathjax

MIT License
124 stars 16 forks source link

Not able to render complexed Sylvester equation #32

Closed kherP closed 1 year ago

kherP commented 1 year ago

Hi, i tried to use this library to render

A^{m\times m}X^{m\times n}+X^{m\times n}B^{n\times n}=C^{m\times n} \\\left[\begin{matrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{matrix} \right] \left[\begin{matrix} x_{11}  \\ x_{21}  \end{matrix}\right] + \left[\begin{matrix} x_{11} \\ x_{21} \end{matrix}\right]  b_{11}     = \left[\begin{matrix} c_{11} \\ c_{22} \end{matrix} \right] 

but it's not rendered properly: image

I tried using the following code:

<MathJaxContext>
      <h2>Basic MathJax example with Latex</h2>
      <MathJax>{`A^{m\\times m}X^{m\\times n}+X^{m\\times n}B^{n\\times n}=C^{m\\times n} \\\\\\left[\\begin{matrix}
  a_{11} & a_{12} \\\\
  a_{21} & a_{22}
  \\end{matrix} \\right] \\left[\\begin{matrix}
  x_{11}  \\\\
  x_{21} 
  \\end{matrix}\\right] + \\left[\\begin{matrix}
  x_{11} \\\\
  x_{21} \\end{matrix}\\right] 
  b_{11}  
    = \\left[\\begin{matrix} c_{11} \\\\ c_{22} \\end{matrix} \\right]`}</MathJax>
    </MathJaxContext>

but in MathJax preview, i can see it rendered perfectly. The only difference is that i added dollar sign for prefix and suffix for the mathjax demo. I tried to do the same in better-react-mathjax but It didn't work.

image

fast-reflexes commented 1 year ago

Hi there!

You have to use the MathJax delimiters set out in the configuration. If you give no configuration, the default applies which means \( and \) are used for inline math. If you supply them, the code works as expected. Perhaps the other library that you mention takes care of this for you but better-react-mathjax aims at being just a wrapper around MathJax that doesn't interfere with regular MathJax operation, therefore you can pick your own delimiters in the configuration and you also have to add the delimiters in code. Please check examples in the documentation.

Sandbox with working samples using two different delimiters

Please close the ticket if this solves your problem :)

kherP commented 1 year ago

it works, thank you!