# Retain original form of formatted equation [duplicate]

I am having trouble getting Mathematica to retain my original equation form. For example:

As you can see, even though I use HoldForm, it still changes the style of my equation. Very frustrating.

• You are expecting too much from HoldForm. Its only interaction with the front-end is to be treated as an invisible wrapper. It gives the form it wraps no protection from output styling by the front-end. Its protection of the form only extends to preventing evaluation in a kernel. – m_goldberg May 8 '14 at 15:28
• Strongly related: "Conversion of expressions by the FrontEnd." – Alexey Popkov May 8 '14 at 16:38
• I think a possible answer to this is in my response to this question: Formula Formatting is Small and Chunky? – Jens May 8 '14 at 20:15

Here you have to enforce fraction on the Boxes level. This is one possible way to do it:

SetAttributes[fraction, Attributes@MakeBoxes];

MakeBoxes[fraction[a_, b_], rest_] ^:=
FractionBox[MakeBoxes[a, rest], MakeBoxes[b, rest]]


Then you can manually transform subexpressions:

fixFractions = # /. Times[a_, Power[b_, -1]] :> fraction[a, b] &;


An example:

(1 + Sqrt[1+8b(b-1)])/2 // HoldForm // fixFractions // TraditionalForm


However, sometimes you might want to leave Times[_, Power[_, -1]] as it is. Good news it's not difficult to control with pattern-matching.

Note: In this case it works perfectly even without attributes for fraction. However, I don't want to remove the SetAttributes[fraction, Attributes@MakeBoxes] part, even though I myself don't clearly understand the reasons. Comments on that matter are very welcome.