# Why Mathematica does not interpret this LaTeX code correctly

ToExpression["$$\\frac{\\partial ^{n} f}{\\partial x^{n}}$$ ",
TeXForm]

It outputs 0 instead of the partial derivative: $$\frac{\partial ^{n} f}{\partial x^{n}}$$

This happens because D[f, {x, n}] evaluates to 0. Mathematica does not find x in the expression f so it assumes that f does not depend on x.

The result of the following might be closer to you goal:

ToExpression["$$\\frac{\\partial ^{n} f(x)}{\\partial x^{n}}$$ ", TeXForm]

Derivative[n][f][x]

• Can output to a standform format like ToString? Jan 25, 2020 at 7:53
• I do not get what you try to say. Please, use full sentences. Jan 25, 2020 at 7:54
• Can we output the result of texform as a string like ToString["\!$$\*FractionBox[\(\*SuperscriptBox[\(\[PartialD]$$, \ $$n$$]f\), $$\[PartialD]\*SuperscriptBox[\(x$$, $$n$$]\),\n\ MultilineFunction->None]\)", StandardForm]. Jan 25, 2020 at 7:59
• What about ToString[ ToExpression["$\\frac{\\partial ^{n} f(x)}{\\partial x^{n}}$ ", TeXForm], InputForm ]? Jan 25, 2020 at 8:03
• ToLaTeXString is not a built-in function. I don't understand what you want. Jan 25, 2020 at 8:04

Another possibility is to use the 3-arg version of ToExpression to prevent evaluation:

ToExpression["$$\\frac{\\partial ^{n} f}{\\partial x^{n}}$$ ", TeXForm, HoldForm]

D[f,{x,n}]

You can use TraditionalForm to format the output as desired:

ToExpression["$$\\frac{\\partial ^{n} f}{\\partial x^{n}}$$ ", TeXForm, HoldForm],
"\!$$\*FormBox[TagBox[FractionBox[ RowBox[{SuperscriptBox[\"\[PartialD]\", \"n\"], \"f\"}], RowBox[{\"\[PartialD]\", SuperscriptBox[\"x\", \"n\"]}],\n\ MultilineFunction->None], HoldForm], TraditionalForm]$$"