-1

I am looking at converting a standard mathematical user input such as

int(3cos(x)+2)

To latex

$\int cos(3x) dx$

And then converting that latex expression to a typsetted math image that can be used on a GUI in real time

How could this be done?

Lewis Kelsey
  • 4,129
  • 1
  • 32
  • 42
  • 2
    http://stackoverflow.com/questions/3867028/converting-a-python-numeric-expression-to-latex – Whud Nov 22 '16 at 13:49

1 Answers1

1

You can also generate the latex expression into an image with sympy.

Check the documentation of sympy. Here's an example:

latexexpr = sin(sqrt(x**2 + 20)) + 1 
preview(latexexpr, viewer='file', filename='result.png')

Result: Result

Taufiq Rahman
  • 5,600
  • 2
  • 36
  • 44
  • Great, just getting a runtime error RuntimeError: latex program is not installed – Lewis Kelsey Nov 22 '16 at 22:02
  • Thought i had texlive installed, turns out not on this vm, might have solved the problem – Lewis Kelsey Nov 22 '16 at 22:15
  • Its working fine, im facing one issue though, i am unable to change the font size and the background colour of the output , i have tried to use preamble from the documentation but to no avail. – Lewis Kelsey Nov 24 '16 at 23:56