# Latex expression \int_{a}^{b} x dx in Mathematica - ToExpression+TexForm error

I tried to convert a Latex expression to Mathematica in this way:

ToExpression["\\int_{a}^{b}{x dx}", TeXForm]


Mathematica gives me an error. How can I get the correct expression in Mathematica?

Thank very much for your time.

Mathematica is expecting a space between the integrand and the $dx$. So, the following works:

ToExpression["\\int_{a}^{b} x \\, dx", TeXForm]


-(a^2/2) + b^2/2

You could see what kind of TeXForm should work by doing the reverse:

ToString[ Unevaluated[Integrate[x, {x, a, b}]], TeXForm ]


"\int_a^b x \, dx"

• Hello @CarlWoll. Is it also possible to get the unevaluated expression? I tried with ToExpression[Unevaluated["\\int_{a}^{b} x \\, dx"], TeXForm], but my statement is blatantly wrong. – Gennaro Arguzzi Oct 27 '17 at 15:03
• Use 3-arg form of ToExpression, e.g., ToExpression[texString, TeXForm, Hold] – Carl Woll Oct 27 '17 at 15:12