32
$\begingroup$

How to convert the $\LaTeX$ format to Mathematica input?

For example, if I have a formula:

$$ \sum_{m_{i}=0}^M\sum_{n_{j}=0}^N \frac{(z_{i}/2)^{m_{i}}(z_{j}/2)^{n_{j}}}{m!n!} $$

in terms of $\LaTeX$ format:

  \sum_{m_{i}=0}^M\sum_{n_{j}=0}^N \frac{(z_{i}/2)^{m_{i}}(z_{j}/2)^{n_{j}}}{m!n!}

How would we convert it to Mathematica input?

$\endgroup$
2

1 Answer 1

50
$\begingroup$

You can use ToExpression.

ToExpression["string", TeXForm, HoldForm]

Paste your content inside quotes and click the button "yes", when the following dialog box opens, in order to escape backslashes and use them verbatim

enter image description here

In your example, Mathematica 12.1 produces the following output

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ It works, but strangely \sum becomes \\sum when I past into the "string"...? $\endgroup$
    – wonderich
    Dec 6, 2016 at 2:44
  • 5
    $\begingroup$ That's because the backslah of the TeX expression is not intended to be interpreted as Mathematica code, so it must be "escaped". The way to do this is to precede it by another backslash. Mathematica is aware of this and offers this transformation when you paste the string. $\endgroup$ Dec 6, 2016 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.