-
Notifications
You must be signed in to change notification settings - Fork 31
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
How to convert division symbol (u+00f7) or chr(247) to latex using py2tex? #63
Comments
This is not currently supported but you can add it in Pytexit. Also add a Test if you want to make sure your change remains forever https://github.com/erwanp/pytexit/blob/master/pytexit/test/test_functions.py (note : in your text above make sure you have correct parenthesis) |
Hi there, let me volunteer to add in support for this. Thanks for the tips on getting started! |
Thanks Wes for your response and analysis of possible solution.
Currently, I am using a workaround solution in which I am handling "÷" symbol outside py2tex as text. But it will be great if we get a clean solution using pytexit / py2tex, if that is possible. |
Understood, I had a look at this today but am still running into the issue of ast.parse(), as it must take "/" as division input, then at which time, we lose track whether it was originally a "/" or a "÷", since ast.parse() only accepts "/". This could use further looking into, perhaps it is possible but a solution will be more complicated. In the meantime, I followed erwanp's suggestion for the unicode table: "Try to add it there ; and replace it by "/" ?"--- this works in the meantime such that at least feeding in the string txt1 = '3/4' + ' ' + chr(247) + ' ' + '8/15' can be parsed, if not ideally, at least mathematically correctly. |
To follow up again, I came up with a second solution that's a bit janky but it appears to work. First, we can convert the "÷" symbol into a magic number "+2146136747+", this way, it validates in ast.parse() as a valid expression thanks to the + symbols. Second, we then ignore the + symbols by checking for this magic number on the left and right nodes. Lastly, when visit_Num(self, n) is called, we check for this magic number, and instead return "\div" instead of the number. This appears to work, passing all tests, and I will submit a second pull request and leave it up for the project author to decide. As this is a bit more complicated and not as clean of a solution. Open to feedback/further edits if necessary. |
Hello Ivr merged your 2nd solution in #64, but looking at your comment I think we'd rather keep the 1st one. Can you reupdate the PR? |
Created a new PR to reflect the 1st option. For Shashukulk, you can to refer to this commit, here you only need to make 3 additions to core.py. If you want to run this custom logic to obtain usage of the divison symbol as you intend. Hope this helps! |
In one of the maths equations, I am having division symbol (u+00f7) or chr(247) as below -
When I use py2tex to convert it into latex, I am getting below error -
Can anyone please suggest / help how to convert this character / such maths characters to LaTex using py2tex?
The text was updated successfully, but these errors were encountered: