I want to display (output) my expressions as I write them .
However StringForm somehow changes internally. (in this example, commutes the adition)
Outside StringForm everything works OK.
How do I prevent this?
Thanks
It looks like a bug in StringForm. Both TraditionalForm[HoldForm[-b + a]] and
TraditionalForm[HoldForm[-b + a]]
StringForm["`1`", HoldForm[-b + a]]
give -b+a, while
-b+a
StringForm["`1`", TraditionalForm[HoldForm[-b + a]]]
gives a-b. You may try with ToString instead of StringForm.
a-b
Gianluca:
A simple change in the definition of my function fixed all, thanks to your suggestion
displayExpr[expr_] := Style[Format[HoldForm[expr], TraditionalForm]]; (Old)
displayExpr[expr_] := Style[ToString[HoldForm[expr], TraditionalForm]]; (New)
I dont know why.
Best regards
But what about the Style, format of the output?
Thanks for the support