TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 7 down vote accepted

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)

share|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

share|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 posting your answer, you agree to the privacy policy and terms of service.

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