# Does a tool exist which can take a LaTeX equation and convert it to a format suitable for evaluation in Wolfram's Mathematica?

I use LaTeX to type up my homework, but as I work I often need to pop things into Mathematica (or manually type them in, or manually use my TI-89, etc.).

Currently, I've been manually translating things like \frac{a}{b} into (a/b) for Mathematica's consumption... is there a tool out there which does this automagically?

• I'm also interested in whether proposed solutions work for Wolfram Alpha. – Rebekah Sep 21 '10 at 22:00
• Is there a similar capability for Maple? All I can find in the documentation is the reverse - LateX export. – rogerl Nov 5 '10 at 13:20
• @rogerl: That deserves a separate question, I think. – Billy ONeal Nov 5 '10 at 14:32

## 1 Answer

Mathematica can do this itself: ToExpression["\\frac{a}{b}", TeXForm].

The mathematica frontend will automatically perform the necessary doubling of the backslashes so long as you are pasting into a string (ie, put the cursor between quotes "" before pasting)

You didn't ask, but you can also go the other way mathematica->Tex: TeXForm[a/b] gives \frac{a}{b}.

You can also use a mixture of TeX and mathematica in a file document.mtex and use the mathematica Splice["document.mtex"] command to replace <*, *> delimited mathematica input by TeXForm mathematica output. Eg:

The derivative of $x^x$ is $<*D[x^x,x]*>$.


Splices to:

The derivative of $x^x$ is $x^x (\log (x)+1)$.

• Too bad it doesn't work with intergals. Thanks +1 and checkmark. – Billy ONeal Sep 23 '10 at 15:58
• It does work with integrals; try 'ToExpression["\\int \\sin(\\sin(x)) \\, dx", TeXForm]' – alfC Oct 6 '11 at 7:34