# Improving TeXForm handling of fraction

TeXForm does not always change fraction a/b to $$\frac{a}{b}$$. If the fraction was an exponent for example, it keeps it a/b.

Is there a way to make TeXForm always change fraction to correct Latex output which is $$\frac{a}{b}$$ regardless of where the fraction is located in the expression?

Here is an example

 TeXForm[3/2]
(*   \frac{3}{2}  *)


But

 TeXForm[y^(3/2)]
(*   y^{3/2}  *)


I prefer the above to be

 y^{\frac{3}{2}}


Which, for me, looks a little better when compiled. Compare for example

$$y^{3032/7}$$ and $$y^{\frac{3032}{7}}$$

Using V 12 on windows.

You will need to adjust the TraditionalForm formatting of such expressions. In order to only affect TeXForm, I think the most convenient approach is to modify a TeXForm internal function so that its behavior is controlled by a global variable:

Unprotect[ConvertTeXExpressionToTeX];
ConvertTeXExpressionToTeX[e_, opts___?OptionQ] /; !TrueQ@$$TeX := Block[ {$$TeX = True},
ConvertTeXExpressionToTeX[e, opts]
]
Protect[ConvertTeXExpressionToTeX];


Now, give your expression a TraditionalForm format that is conditioned on the global variable $TeX: Unprotect[Power]; Power /: MakeBoxes[a_^b_Rational, TraditionalForm] /; TrueQ @$TeX := MakeBoxes[
a^Defer[b],

Finally, you should have the desired output from TeXForm:
TeXForm[y^(3/2)]