Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some LaTeX symbols not rendering #56

Closed
hypnocill opened this issue Sep 24, 2021 · 6 comments
Closed

Some LaTeX symbols not rendering #56

hypnocill opened this issue Sep 24, 2021 · 6 comments

Comments

@hypnocill
Copy link

hypnocill commented Sep 24, 2021

I'm using MathView to render LaTeX exported from https://cortexjs.io/mathlive/demo/. It works well for the most part but some symbols are not rendering (see screenshot). They appear in the same way in the www.mathjax.org/#demo - red, without proper rendering.
Example troublesome latex would be: \exponentialE\imaginaryI\pi - it renders well in cortexjs but doesn't in react-native-math-view

Is there a way to render those symbols properly? Or to add them to the library myself and instruct the library how to render them, if needed?

Also, a latex with coloring exported from cortejx like so: \colorbox{#fff1c2}{[ \textcolor{#63b215}{x+42\operatorname{sign}(\placeholder{⬚})} ]}
It results in an error - '[' is only supported in math mode. If I wrap the whole latex with '$' for math mode - it results in another error - '#' macro is not supported in math mode.

Currently I do: replaceAll(String.raw\[, '$') and for the other symbols that don't render like \exponentialE -> e before passing the latex to the mathview which works but seems like a bad workaround.

In conclusion - is there a good way to safely and reliably render the output from https://cortexjs.io/mathlive/demo/ in react-native-math-view without using workarounds like find and replace?

Screenshot 2021-09-24 at 12 03 59
.

@ShaMan123
Copy link
Owner

ShaMan123 commented Sep 24, 2021

Hi, you should define macros so mathjax knows what to do.
Also it is likely you need to escape backslashes (\\).
Refer to this commit: 6556598

@ShaMan123
Copy link
Owner

for example

<MathView
   config={{ macros: {
                'placeholder': ''
            }}
/>

@hypnocill
Copy link
Author

The macros work but they are virtually the same as 'find and replace'. And the issue remains - we can't be sure we've caught all unknown tags that come from the https://cortexjs.io/mathlive/demo/ library.
We searched for 'exponentialE' in the mathjax's react native lib source code and it seems to be present in a few places yet it doesn't render.
Our issue is that with macros we can't be sure that we'll render all tags that could possibly come from cortexjs and it's very important for us to be sure that we can render the latex properly.

@pkra
Copy link

pkra commented Sep 24, 2021

Random bystander here. Both mathlive and mathjax are completely separate systems, even if both use TeX-like syntax (and TeX itself is different still). If you use one tool for authoring and another for rendering, you're bound to run into such issues.

The relevant docs are http://docs.mathjax.org/en/latest/input/tex/macros/index.html and https://cortexjs.io/mathlive/reference/commands/. You can diff them and create all missing macros -- or do the community a favor and create a proper MathJax extension.

@ShaMan123
Copy link
Owner

ShaMan123 commented Sep 24, 2021

Thanks @pkra for the clear and accurate comment.
Rendering math is tough, lots of workarounds are used getting this lib working.

@hypnocill
Copy link
Author

Thank you very much for the answers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants