fast-reflexes / better-react-mathjax

MIT License
124 stars 16 forks source link

Not able to use MathJax v2 #39

Closed petermarks12 closed 1 year ago

petermarks12 commented 1 year ago

I have an equation that is not wrapping on mobile devices and resulting in horizontal scroll bar. I have tried to look for possible solution and but most of them referring to use Mathjax v2. I tried to do the same on Next JS app and constantly getting this error. Code and error are given below.

Note: I am not using any other MathJax context in my entire app. There is only 1 context defined in the _app.js

`

    </MathJaxContext>`

Error: Cannot use MathJax versions 2 and 3 simultaneously in the same app due to how MathJax is set up in the browser; either you have multiple MathJaxContexts with different versions or you have mounted and unmounted MathJaxContexts with different versions. Please stick with one version of MathJax in your app. File an issue in the project Github page if you need this feature.

pkra commented 1 year ago

Not immediately helpful but just fyi: MathJax v4 will add support for linebreaks again, see https://github.com/mathjax/MathJax-src/releases/tag/4.0.0-alpha.1#linebreaking.

fast-reflexes commented 1 year ago

Never encountered this before when you only have one MathJaxContext so the obvious questions are whether you are importing some other library that uses better-react-mathjax as well or if you have forgotten something? That message is literally only displayed when the MathJaxContext encounters an existing MathJaxBaseContext with a version different than the one you have explicitly set. Try to simulate the problem in a codesandbox and I can have a look :)

petermarks12 commented 1 year ago

I have checked it multiple times, but seems there is no other MathJax context. I will try to simulate the problem in codesandbox. So far for the wrapping issue, i have found the following solution and it seems to be working.

mjx-math.MJX-TEX {
  white-space: normal !important;
  line-height: 0.5 !important;
}
fast-reflexes commented 1 year ago

Try to comment out code, piece by piece until you ONLY have the MathJaxContext left in the app and see when the error disappears.

fast-reflexes commented 1 year ago

Feel free to reopen if you can provide more detail. For now, it's not possible to trouble-shoot.