I'm trying to convert calculator input to LaTeX. if a user inputs this:
(3x^(x+(5/x)+(x/33))+y)/(32 + 5)
I have to convert it to this:
frac{3x^(x+frac{5}{x}+frac{x}{33})+y}{32 + 5x}
however I am having issues with determining when a numerator begins and ends. Any suggestions?
Have a look at compiler
compiler.parse('(3*x**(x+(5/x)+(x/33))+y)/(32 + 5)')
returns
Module(None, Stmt([Discard(Div((Add((Mul((Const(3), Power((Name('x'), Add((Add((Name('x'), Div((Const(5), Name('x'))))), Div((Name('x'), Const(33))))))))), Name('y'))), Add((Const(32), Const(5))))))]))
which could be more easily converted to LaTeX code. You will have to write methods, that handle each code (Div, Add, Const, Name, Power,...) and its parameters recursively and return appropriate LateX code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With