i'd like to test if a string, once transformed into lowercase is equal to a given string. Here a MWE of what i'm talking about :



\planetwo{ and  }\planethree{ are }
\ifx\planetwo\planethree{the same}\else{not the same}\fi.


Of course when i test \meaning\planetwo and \meaning\planethree i can see the two commands are not the same, but i just want to test what they expand to.

I tried a few \expandafter here and there, but without any success.


\lowercase is not expandable, so you're doing the same as


and therefore \planethree is different from \planetwo.

You can do


but a different strategy can be better for more complex situations:


With this code you delay the application of \lowercase when the replacement text for \planethree has already been completely expanded.

Let's see how it works.

  1. The \begingroup is used just to set a temporary value to \x

  2. We \edef the macro \x, so \planeone will be completely expanded as it should, but \lowercase, \def and \planethree are left untouched

  3. After the \edef, the replacement text of \x will be

  4. Executing \x will do the \lowercase that will change the case of the letters

  5. After that operation,


    is put back in the main input stream, so the group started with \begingroup is ended and the definition is performed.

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.