What is the equivalent of \ifthenelse{<statement>}{<iftrue>}{<iffalse>} when using expl3 syntax?

  • 2
    expl3 has different conditional macros, such as \bool_if:NTF \some_bool {true branch}{false branch} or \seq_if_in:NnTF etc, depending on the 'variable' type and the precise application usage – user31729 Feb 16 at 19:39
  • Let's say I want to check whether two integers are equal or not, would something like \bool_if:{ \equal{#1}{#2} }{ <iftrue> }{ <iffalse> } work? – noibe Feb 16 at 19:42
  • 4
    No, since integers are not bool, at least not that way. \int_compare:nNnTF {#1} = {#2} {true}{false} -- the \equal etc. syntax is not available in expl3 and I found \ifthenelse never convincing -- see the interface3 manual please – user31729 Feb 16 at 19:44
  • 1
    You could do \bool_if:nTF { \int_compare_p:nNn {#1} = {#2} } { true } { false }, but as @ChristianHupfer says normally one would use just the basic int comparison. – Joseph Wright Feb 16 at 19:46
  • 3
    @ChristianHupfer No, quite the opposite, but it's using the general 'do some comparisons' syntax – Joseph Wright Feb 16 at 19:48

Your Answer

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

Browse other questions tagged or ask your own question.