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?


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

  • 1
    $\begingroup$ It works, but strangely \sum becomes \\sum when I past into the "string"...? $\endgroup$ – wonderich Dec 6 '16 at 2:44
  • 4
    $\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$ – Fred Dec 6 '16 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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