I've written a command that takes a number of minutes and formats it like so: Xh Xmin.
The logic of the command works fine, but if I use it in combination with other command or itself, it produces unwanted spacing in front of the text.
The Command
\newcommand{\timeFormat}[1]
{
\def\hours{}
\def\minutes{}
\IfInteger{#1}
{
\ifnum\intcalcDiv{#1}{60} > 0
\appto\hours{\intcalcDiv{#1}{60}}
\fi
\ifnum\intcalcMod{#1}{60} > 0
\appto\minutes{\intcalcMod{#1}{60}}
\fi
\ifthenelse{\equal{\hours}{}}
{\ifthenelse{\equal{\minutes}{}}
{}
{\minutes min}}
{\ifthenelse{\equal{\minutes}{}}
{\hours h}
{\hours h \minutes min}}
}{}
}
Dependencies
\usepackage{intcalc}
\usepackage{xstring}
Usage
\timeFormat{100}\timeFormat{1}\timeFormat{60}
Result
So far, I haven't figured out how to get rid of the spacing and I've run out of ideas.
How can i fix this?


\ifnumtests and the ones following the first two arguments of\ifthenelse. – egreg Aug 31 '17 at 11:09%character to the end of the offending lines of your macro (or each line for assurance). See https://tex.stackexchange.com/questions/7453/what-is-the-use-of-percent-signs-at-the-end-of-lines – Steven B. Segletes Aug 31 '17 at 11:13