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



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?


Posted 2016-12-06T01:08:23.110

Reputation: 603



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


Posted 2016-12-06T01:08:23.110

Reputation: 620

1It works, but strangely \sum becomes \sum when I past into the "string"...? – wonderich – 2016-12-06T02:44:19.913

4That'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. – Fred – 2016-12-06T02:49:40.273