[Tex/LaTex] How to typeset arbitrary fractions like the standard symbol for .5 = ½

fractions

I know I've seen somewhere how to typeset 1/2 as ½, but with arbitrary fractions (that is, a macro that takes two arguments and makes the first denominator and the second numerator…). Now I can't seem to find it.

How do I typeset an arbitrary fraction the same way as ½?

Best Answer

You want xfrac

\documentclass{article}
\usepackage{xfrac}
\begin{document}
\sfrac{12}{3}
\end{document}

output

There are differences between xfrac and nicefrac (detailed in the manual for xfrac), particularly if you are using fonts other than Computer Modern.