In this post, a solution is given to the problem of defining a command which tests equality of two strings, sufficiently robust (in comparison to \ifthenelse) to admit complicated arguments (e.g. containing commands or environments). But now, i would like to adapt it to perform a test on 1 argument in the form "IF arg= a OR arg=b THEN ... ELSE ...", where "a" and "b" or fixed. My attempt is :


\testIfNotTrivial{a}{true}{false} - 
\testIfNotTrivial{b}{true}{false} - 


But it does not have the expected (from me) behaviour : false - False - true


Without a MWE this is untested but in your second branch the\expandafter only gets rid of one \fi you still have the outer \fi left so looks like you would want


(no need for % after a command name)

| improve this answer | |

You really should give LaTeX3 a try, if you have many tests like this:

      \str_if_eq_p:nn { #1 } { a } || \str_if_eq_p:nn { #1 } { b }
\testOR{a}{true}{false} --
\testOR{b}{true}{false} --
\testOR{coucou}{true}{false} --

This gives

true – true – false – false

| improve this answer | |
  • Ok, maybe you are right. I'm just afraid of learning new syntaxes... – nicolas roy Feb 7 '12 at 13:30
  • Where could i find an introduction to these latex3 commands ? – nicolas roy Feb 9 '12 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.