[texhax] what is wrong with \ifthenelse?

Ulrike Fischer news3 at nililand.de
Sun Aug 9 12:09:29 CEST 2009


Am Sat, 8 Aug 2009 22:55:41 -0700 (PDT) schrieb Brandon Kuczenski:

> Hi everyone,
> 
> Thanks for your enduring patience with me and others..  I do not 
> understand, what is wrong with the following minimal example which uses 
> the ifthen package?  I get the error:
> ! Missing = inserted for \ifnum.
> 
> 
> 
> \documentclass[letterpaper]{article}
> \usepackage{ifthen}
> 
> \newcommand{\whichisgreater}[2]{%
>    \ifthenelse{#1 < #2}{%
>      Two!
>      #2
>    }{%
>      One!
>      #1
>    }
> }
> 
> \begin{document}
> \whichisgreater{0.3}{0.5}
> 
> \end{document}

The numbers must be integers. Use lengthtest:

\documentclass[letterpaper]{article}
\usepackage{ifthen}

\newcommand{\whichisgreater}[2]{%
   \ifthenelse{\lengthtest{#1cm < #2cm}}{%
     Two!
     #2
   }{%
     One!
     #1
   }
}

\begin{document}
\whichisgreater{0.3}{0.5}

\end{document}
-- 
Ulrike Fischer 



More information about the texhax mailing list