StringForm changes the way i want my output

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

You can produce strings with the desired ordering by using a construction like Row[{“x”,“y”, . . .}]

But what about the Style, format of the output?

Thanks for the support

It looks like a bug in StringForm. Both TraditionalForm[HoldForm[-b + a]] and

StringForm["`1`", HoldForm[-b + a]]

give -b+a, while

StringForm["`1`", TraditionalForm[HoldForm[-b + a]]]

gives a-b. You may try with ToString instead of StringForm.

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 don’t know why.

Best regards