0

i read user manual of xifthen package.

But i don't find "Not equal" command. How can i set below rule:

\ifthenelse \cnttest{\Var} equal A: Do newcommand AAA
\ifthenelse \cnttest{\Var} equal B: Do newcommand BBB
\ifthenelse \cnttest{\Var} equal C: Do newcommand CCC
\ifthenelse \cnttest{\Var} not equal A, AND not equal B, AND not equal C: Do newcommand ABC

And other Rule is below:

  \ifthenelse \cnttest{\Var} not equal A, AND not equal B, AND not equal C: Do newcommand ABC

Thank in advance

1 Answer 1

2

The \ifthenelse macro takes three arguments:

\ifthenelse{<test>}{<code for true>}{<code for false>}

Thus you can simply nest the calls:

\ifthenelse{\cnttest{\Var}{=}{1}}{Case 1}{%
  \ifthenelse{\cnttest{\Var}{=}{2}}{Case 2}{%
    \ifthenelse{\cnttest{\Var}{=}{3}}{Case 3}{%
       {Case not 1, not 2, not 3}%
    }%
  }%
}
3
  • thank, how can i set \ifthenelse{\cnttest \Var equal Not 1, do case A1 ? \ifthenelse{\cnttest \Var equal NOT 1 AND NOT 3 do case A13...?
    – latexforti
    Aug 23, 2019 at 11:27
  • 1
    @latexforti It would be better if you tell what’s your real aim.
    – egreg
    Aug 23, 2019 at 13:42
  • Thanks. i have datatools: tex.stackexchange.com/questions/505127/… and \var is range (0-100). If var is not 0,50,100 then call newcommand XXX
    – latexforti
    Aug 23, 2019 at 13:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .