This is the most bizzar thing I saw with Mathematica TeXForm. Could someone please explain why it happens and if there is a workaround?
First, will show screen shot. I have an expression, when I have 2*x
in it, TeXForm generates \exp
for exp
when using With[{...},TeXForm[HoldForm[...]]
. When changing 2*x
to 1*x
, now e
Latex is generated, same as TeXForm
This only happens when using With[{...},TeXForm[HoldForm[...]]
construct. Otherwise TeXForm
works same in both cases. But why?
Here is the code
ClearAll[x]
expr = 1/(Exp[(5*x - 2)/((10*x^2 - 10*x)*Exp[x] + (2*x))])
With[{z0 = expr},
exprAsLatex = TeXForm[HoldForm[z0]];
];
exprAsLatex
expr = 1/(Exp[(5*x - 2)/((10*x^2 - 10*x)*Exp[x] + (1*x))])
With[{z0 = expr},
exprAsLatex = TeXForm[HoldForm[z0]];
];
exprAsLatex
Using 12.3.1 on windows 10.
You might ask, why Am I using HoldForm
? the reason is that this is part of larger code, where I needed to prevent evaluation of an expression while taking its Latex. The above is a MWE of the problem.
TeXForm
works the same on both 2*x
and 1*x
:
The problem only shows up when using the With[{...},TeXForm[HoldForm[...]]
method.
\exp
in latex. I never used it and Mathematica did not use it before, that is why. All the CAS systems I use generatee
forexp
. Still, why the difference in output is my main question. I'll adjust the question now. $\endgroup$TeXForm
is just converting theTraditionalForm
to LaTeX. ReplaceTeXForm
withTraditionalForm
in your code to see this. Why isTraditionalForm
formatting these two expressions differently? I don't know, that is a good question. $\endgroup$