mathjax-react icon indicating copy to clipboard operation
mathjax-react copied to clipboard

ams extension not loaded?

Open JoHae opened this issue 5 years ago • 2 comments

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?

JoHae avatar Feb 04 '21 19:02 JoHae

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

CharlieMcVicker avatar Feb 06 '21 00:02 CharlieMcVicker

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.

JoHae avatar Feb 07 '21 16:02 JoHae