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

2 Answers 2


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)


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

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

You must log in to answer this question.

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