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?
Best 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 mathematicaSplice["document.mtex"]
command to replace<*
,*>
delimited mathematica input by TeXForm mathematica output. Eg:Splices to: