CharlieMcVicker / mathjax-react

React Component Library for MathJax
33 stars 14 forks source link

ams extension not loaded? #12

Open JoHae opened 3 years ago

JoHae commented 3 years ago

Love your component. I am using the following versions:

        "mathjax-full": "^3.1.2",
        "mathjax-react": "^1.0.6",

As it seems the amsmath extension is not loaded. E.g.:

<MathComponent tex={String.raw`\approxeq`} />

throws me the error:

Uncaught (in promise) Undefined control sequence \approxeq

or am I am missing something here?

CharlieMcVicker commented 3 years ago

Looks like we didn't set up loading extra packages in this project - I've been very busy since this was released, but you can easily add the package yourself on a fork by changing this line:

https://github.com/CharlieMcVicker/mathjax-react/blob/4bfd68511ba863b0bca41d475d213420b8fdb16d/src/utils/convert.ts#L21

JoHae commented 3 years ago

Thanks for pointing me to the right direction. I got it to work in my fork by including the import for the ams configuration.

The packages intialization you posted already included the ams package which made me suspicious. So after some digging I found the problem: Since you specify the 'base' package the input/tex-base is used (see mathjax doc) which does not include any additional latex packages/maros/environments. Thus, we must include any additional package manually. Unfortunately, it is not enough to specify the name of the package but also the configuration module must be imported. If you intended to load the ams package I am glad to do a pull request, otherwise it would be good to delete the 'ams' from

https://github.com/CharlieMcVicker/mathjax-react/blob/4bfd68511ba863b0bca41d475d213420b8fdb16d/src/utils/convert.ts#L21

It would be nice to see a dynamic way of loading packages when using the MathComponent (maybe via props?) in a future release.