I felt pretty good about myself until I discovered that LaTex is erroneously inserting a huge amount of white space before and after my command. I've tried many different changes but can't seem to put my finger on the problem.
Here's my fracreduce package code:
Code: Select all
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{fracreduce}[04/06/2011 Converts database input (64ths) into latex fractions]
\RequirePackage{ifthen}
\RequirePackage{units}
% #1 is the whole number, #2 is the decimal, both fed from database
\newcommand{\fracreduce}[2]
{
\ifthenelse{\equal{#1}{0}}{\fracreduce{}{#2}}
{
\ifthenelse{\equal{#2}{1}}{\unitfrac[#1]{1}{64}}{}
\ifthenelse{\equal{#2}{2}}{\unitfrac[#1]{1}{32}}{}
\ifthenelse{\equal{#2}{3}}{\unitfrac[#1]{3}{64}}{}
\ifthenelse{\equal{#2}{4}}{\unitfrac[#1]{1}{16}}{}
\ifthenelse{\equal{#2}{5}}{\unitfrac[#1]{5}{64}}{}
\ifthenelse{\equal{#2}{6}}{\unitfrac[#1]{3}{32}}{}
\ifthenelse{\equal{#2}{7}}{\unitfrac[#1]{7}{64}}{}
\ifthenelse{\equal{#2}{8}}{\unitfrac[#1]{1}{8}}{}
\ifthenelse{\equal{#2}{9}}{\unitfrac[#1]{9}{64}}{}
\ifthenelse{\equal{#2}{10}}{\unitfrac[#1]{5}{32}}{}
\ifthenelse{\equal{#2}{11}}{\unitfrac[#1]{11}{64}}{}
\ifthenelse{\equal{#2}{12}}{\unitfrac[#1]{3}{16}}{}
\ifthenelse{\equal{#2}{13}}{\unitfrac[#1]{13}{64}}{}
\ifthenelse{\equal{#2}{14}}{\unitfrac[#1]{7}{32}}{}
\ifthenelse{\equal{#2}{15}}{\unitfrac[#1]{15}{64}}{}
\ifthenelse{\equal{#2}{16}}{\unitfrac[#1]{1}{4}}{}
\ifthenelse{\equal{#2}{17}}{\unitfrac[#1]{17}{64}}{}
\ifthenelse{\equal{#2}{18}}{\unitfrac[#1]{9}{32}}{}
\ifthenelse{\equal{#2}{19}}{\unitfrac[#1]{19}{64}}{}
\ifthenelse{\equal{#2}{20}}{\unitfrac[#1]{5}{16}}{}
\ifthenelse{\equal{#2}{21}}{\unitfrac[#1]{21}{64}}{}
\ifthenelse{\equal{#2}{22}}{\unitfrac[#1]{11}{32}}{}
\ifthenelse{\equal{#2}{23}}{\unitfrac[#1]{23}{64}}{}
\ifthenelse{\equal{#2}{24}}{\unitfrac[#1]{3}{8}}{}
\ifthenelse{\equal{#2}{25}}{\unitfrac[#1]{25}{64}}{}
\ifthenelse{\equal{#2}{26}}{\unitfrac[#1]{13}{32}}{}
\ifthenelse{\equal{#2}{27}}{\unitfrac[#1]{27}{64}}{}
\ifthenelse{\equal{#2}{28}}{\unitfrac[#1]{7}{16}}{}
\ifthenelse{\equal{#2}{29}}{\unitfrac[#1]{29}{64}}{}
\ifthenelse{\equal{#2}{30}}{\unitfrac[#1]{15}{32}}{}
\ifthenelse{\equal{#2}{31}}{\unitfrac[#1]{31}{64}}{}
\ifthenelse{\equal{#2}{32}}{\unitfrac[#1]{1}{2}}{}
\ifthenelse{\equal{#2}{33}}{\unitfrac[#1]{33}{64}}{}
\ifthenelse{\equal{#2}{34}}{\unitfrac[#1]{17}{32}}{}
\ifthenelse{\equal{#2}{35}}{\unitfrac[#1]{35}{64}}{}
\ifthenelse{\equal{#2}{36}}{\unitfrac[#1]{9}{16}}{}
\ifthenelse{\equal{#2}{37}}{\unitfrac[#1]{37}{64}}{}
\ifthenelse{\equal{#2}{38}}{\unitfrac[#1]{19}{32}}{}
\ifthenelse{\equal{#2}{39}}{\unitfrac[#1]{39}{64}}{}
\ifthenelse{\equal{#2}{40}}{\unitfrac[#1]{5}{8}}{}
\ifthenelse{\equal{#2}{41}}{\unitfrac[#1]{41}{64}}{}
\ifthenelse{\equal{#2}{42}}{\unitfrac[#1]{21}{32}}{}
\ifthenelse{\equal{#2}{43}}{\unitfrac[#1]{43}{64}}{}
\ifthenelse{\equal{#2}{44}}{\unitfrac[#1]{11}{16}}{}
\ifthenelse{\equal{#2}{45}}{\unitfrac[#1]{45}{64}}{}
\ifthenelse{\equal{#2}{46}}{\unitfrac[#1]{23}{32}}{}
\ifthenelse{\equal{#2}{47}}{\unitfrac[#1]{47}{64}}{}
\ifthenelse{\equal{#2}{48}}{\unitfrac[#1]{3}{4}}{}
\ifthenelse{\equal{#2}{49}}{\unitfrac[#1]{49}{64}}{}
\ifthenelse{\equal{#2}{50}}{\unitfrac[#1]{25}{32}}{}
\ifthenelse{\equal{#2}{51}}{\unitfrac[#1]{51}{64}}{}
\ifthenelse{\equal{#2}{52}}{\unitfrac[#1]{13}{16}}{}
\ifthenelse{\equal{#2}{53}}{\unitfrac[#1]{53}{64}}{}
\ifthenelse{\equal{#2}{54}}{\unitfrac[#1]{27}{32}}{}
\ifthenelse{\equal{#2}{55}}{\unitfrac[#1]{55}{64}}{}
\ifthenelse{\equal{#2}{56}}{\unitfrac[#1]{7}{8}}{}
\ifthenelse{\equal{#2}{57}}{\unitfrac[#1]{57}{64}}{}
\ifthenelse{\equal{#2}{58}}{\unitfrac[#1]{29}{32}}{}
\ifthenelse{\equal{#2}{59}}{\unitfrac[#1]{59}{64}}{}
\ifthenelse{\equal{#2}{60}}{\unitfrac[#1]{15}{16}}{}
\ifthenelse{\equal{#2}{61}}{\unitfrac[#1]{61}{64}}{}
\ifthenelse{\equal{#2}{62}}{\unitfrac[#1]{31}{32}}{}
\ifthenelse{\equal{#2}{63}}{\unitfrac[#1]{63}{64}}{}
}
}
This code works:
Code: Select all
\documentclass[letterpaper]{report}
\usepackage{units}
\begin{document}
It seems that \unitfrac[5]{5}{8} look nice here!
\end{document}
Code: Select all
\documentclass[letterpaper]{report}
\usepackage{fracreduce}
\begin{document}
Why does \fracreduce{5}{40} take up so much space???
\end{document}
Thanks in advance for any help!