I'm creating an invoice in LaTeX and I've entered the hours I've worked as decimals (for example, 1, 1.5, 0.75, 2.25), but I want to display those decimals as fractions (1, 1½, ¾, 2¼).
(The reason I've entered the hours worked as a decimal is so I can perform simple invoice math with the fp package along the lines of this answer)
For a little context, here's the synopsis of the macro I created that includes the number of hours worked:
\lineitem{DATE}{HOURS}{RATE}{PROJECT}{DESCRIPTION}
The conversions I have in mind are pretty simple:
\documentclass{article}
\usepackage{xfrac}
\begin{document}
\begin{tabular}{r @{} l | r @{\hspace{0.1em}} l}
\multicolumn{2}{c}{Given...} & \multicolumn{2}{c}{Output} \\
\hline
1 & & 1 & \\
1 & .5 & 1 & \sfrac{1}{2} \\
0 & .75 & \sfrac{3}{4} & \\
2 & .25 & 2 & \sfrac{1}{4} \\
\end{tabular}
\end{document}
(I'm not married to \sfrac
for displaying fractions, it's just the first package I reached for)
Is there an off-the-shelf package that will do what I want? If not, can anyone give me a few pointers how I might go about implementing my own conversion/display logic?