Inspired by the @ybeltukov 's answer to this question, if I have the following polynomial
poly = a^2 + (a^2 + b^2 - c^2)*x + b^2*x^2; var = x; this generates boxes out of a polynomial to be displayed in canonical order:
MakeBoxes[+##] & @@ (var^#1[[1]] #2 & @@@ CoefficientRules[poly, var]) % // DisplayForm // TraditionalForm $b^2 x^2 + (a^2 +b^2 -c^2)x + a^2$
But if I use the same construction to define MakeBoxes for my function mypoly in TraditionalForm
MakeBoxes[mypoly[poly_, var_], TraditionalForm] := MakeBoxes[+##] & @@ (var^#1[[1]] #2 & @@@ CoefficientRules[poly, var]) Then asking it to display in TraditionalForm
mypoly[a^2 + x^2 b^2 + x (a^2 + b^2 - c^2), x] // TraditionalForm does not yield the correct order:
$x(a^2 +b^2 -c^2) + a^2 +b^2 x^2$
Why? and what can I do to get the right order?

HoldFormaround the+##in MakeBoxes it works:MakeBoxes[mypoly[poly_, var_], TraditionalForm] := MakeBoxes[HoldForm[+##]] & @@ (var^#1[[1]] #2 & @@@ CoefficientRules[poly, var])$\endgroup$HoldFormchanges the output only in that it wraps the resulting expression into aTagBox, which again I'm not really sure what it does (the docs say thatTagBoxsomehow helps "guiding the interpretation of the boxes") $\endgroup$+##, nice trick. $\endgroup$