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]
ToString
?
$\endgroup$
Commented
Jan 25, 2020 at 7:53
ToString["\!\(\*FractionBox[\(\*SuperscriptBox[\(\[PartialD]\), \ \(n\)]f\), \(\[PartialD]\*SuperscriptBox[\(x\), \(n\)]\),\n\ MultilineFunction->None]\)", StandardForm]
.
$\endgroup$
Commented
Jan 25, 2020 at 7:59
ToString[ ToExpression["$ \\frac{\\partial ^{n} f(x)}{\\partial x^{n}} $ ", TeXForm], InputForm ]
?
$\endgroup$
Commented
Jan 25, 2020 at 8:03
ToLaTeXString
is not a built-in function. I don't understand what you want.
$\endgroup$
Commented
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:
TraditionalForm[%]
If you really want a string, you can use ToString
:
ToString[
ToExpression["$ \\frac{\\partial ^{n} f}{\\partial x^{n}} $ ", TeXForm, HoldForm],
TraditionalForm
]
"\!\(\*FormBox[TagBox[FractionBox[ RowBox[{SuperscriptBox[\"\[PartialD]\", \"n\"], \"f\"}], RowBox[{\"\[PartialD]\", SuperscriptBox[\"x\", \"n\"]}],\n\ MultilineFunction->None], HoldForm], TraditionalForm]\)"