1 | initial version |

Hello, @StevenClontz! I don't know if this solves the general case of your question, but it does solve the particular example your present. Write the following:

```
def latex_frac(frac):
if frac == 0: return '0'
num = frac.numerator()
den = frac.denominator()
if den == 1: return str(num)
return r'\frac{' + str(num) + '}{' + str(den) + '}'
```

You can then call this functions like this:

```
latex_frac((2*x+4)/(x^2+1)^2)
```

which will give the result you want.

I hope this helps!

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.