How to compare number from newenvironment argument

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












I am trying to create a new environment as follows



newenvironmentletters[1]%
vspace-3mm
ifnum #1=1%
else
beginmulticols#1
fi
beginenumerate[label=textbf(alph*)]
%
endenumerate
ifnum #1=1%
else
endmulticols
fi
vspace-5mm



My question is: Why doesn't it work?!



Note: this is not a duplicate from this post, since I don't want to do the RenewDocumentEnvironment. Instead, I want to create a new environment.










share|improve this question

























    up vote
    6
    down vote

    favorite












    I am trying to create a new environment as follows



    newenvironmentletters[1]%
    vspace-3mm
    ifnum #1=1%
    else
    beginmulticols#1
    fi
    beginenumerate[label=textbf(alph*)]
    %
    endenumerate
    ifnum #1=1%
    else
    endmulticols
    fi
    vspace-5mm



    My question is: Why doesn't it work?!



    Note: this is not a duplicate from this post, since I don't want to do the RenewDocumentEnvironment. Instead, I want to create a new environment.










    share|improve this question























      up vote
      6
      down vote

      favorite









      up vote
      6
      down vote

      favorite











      I am trying to create a new environment as follows



      newenvironmentletters[1]%
      vspace-3mm
      ifnum #1=1%
      else
      beginmulticols#1
      fi
      beginenumerate[label=textbf(alph*)]
      %
      endenumerate
      ifnum #1=1%
      else
      endmulticols
      fi
      vspace-5mm



      My question is: Why doesn't it work?!



      Note: this is not a duplicate from this post, since I don't want to do the RenewDocumentEnvironment. Instead, I want to create a new environment.










      share|improve this question













      I am trying to create a new environment as follows



      newenvironmentletters[1]%
      vspace-3mm
      ifnum #1=1%
      else
      beginmulticols#1
      fi
      beginenumerate[label=textbf(alph*)]
      %
      endenumerate
      ifnum #1=1%
      else
      endmulticols
      fi
      vspace-5mm



      My question is: Why doesn't it work?!



      Note: this is not a duplicate from this post, since I don't want to do the RenewDocumentEnvironment. Instead, I want to create a new environment.







      environments conditionals






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      Brasil

      335312




      335312




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          If you look at the log you'll see that the first thing TeX complains about is:



          ! Illegal parameter number in definition of endletters.
          <to be read again>
          1
          l.22 }


          That's because you tried to use #1 in the end part of the environment, but you can't use the arguments passed to the begin part in the end part of an environment.



          If you were to do that, then the usage of the environment would have to be
          something like this:



          beginletters1
          item stuff
          endletters1


          passing the argument to endletters too.



          To do what you want you need to devise another way to pass that information to the end part. For instance, with a newif:



          documentclassarticle
          usepackageenumitem
          usepackagemulticol

          newififLettersMulticol
          newenvironmentletters[1]%
          vspace-3mm
          ifnum #1=1
          else
          LettersMulticoltrue
          beginmulticols#1
          fi
          beginenumerate[label=textbf(alph*)]
          %
          endenumerate
          ifLettersMulticol
          endmulticols
          fi
          vspace-5mm


          begindocument

          beginletters1
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          beginletters2
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          enddocument



          Also, as it's been noted in the comments, it's not a good idea to add a % at the end of the line in ifnum tests (and a couple other cases too). When TeX is scanning the numbers in the ifnum test, it is expanding tokens, and will continue to do so until something that is not a number is found. For instance, the following (perhaps idiotic, but serves as demonstration) code



          ifnum1=0%
          ifnum2=2
          1%
          else
          2%
          fi
          a%
          else
          b%
          fi


          produces a, instead of b, as someone that took a quick glance at the ifnum1=0 would guess. If, however, you remove the very first %, the output is b.



          Also, a missing % at the end of a ifnum#1=1 test will not appear in the output, because TeX's number scanning mechanism says that a number can be followed by an optional space, so this one is safe. To be sure, of course, one can end the scanning of the ifnum test with relax: ifnum#1=1relax.



          In this particular case, the % wouldn't casuse troubles, but it's probably better to be on the safe side.






          share|improve this answer






















          • maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
            – jfbu
            2 days ago






          • 1




            @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
            – egreg
            yesterday










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            yesterday










          • @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            yesterday










          • +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
            – jfbu
            yesterday










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460011%2fhow-to-compare-number-from-newenvironment-argument%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          6
          down vote



          accepted










          If you look at the log you'll see that the first thing TeX complains about is:



          ! Illegal parameter number in definition of endletters.
          <to be read again>
          1
          l.22 }


          That's because you tried to use #1 in the end part of the environment, but you can't use the arguments passed to the begin part in the end part of an environment.



          If you were to do that, then the usage of the environment would have to be
          something like this:



          beginletters1
          item stuff
          endletters1


          passing the argument to endletters too.



          To do what you want you need to devise another way to pass that information to the end part. For instance, with a newif:



          documentclassarticle
          usepackageenumitem
          usepackagemulticol

          newififLettersMulticol
          newenvironmentletters[1]%
          vspace-3mm
          ifnum #1=1
          else
          LettersMulticoltrue
          beginmulticols#1
          fi
          beginenumerate[label=textbf(alph*)]
          %
          endenumerate
          ifLettersMulticol
          endmulticols
          fi
          vspace-5mm


          begindocument

          beginletters1
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          beginletters2
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          enddocument



          Also, as it's been noted in the comments, it's not a good idea to add a % at the end of the line in ifnum tests (and a couple other cases too). When TeX is scanning the numbers in the ifnum test, it is expanding tokens, and will continue to do so until something that is not a number is found. For instance, the following (perhaps idiotic, but serves as demonstration) code



          ifnum1=0%
          ifnum2=2
          1%
          else
          2%
          fi
          a%
          else
          b%
          fi


          produces a, instead of b, as someone that took a quick glance at the ifnum1=0 would guess. If, however, you remove the very first %, the output is b.



          Also, a missing % at the end of a ifnum#1=1 test will not appear in the output, because TeX's number scanning mechanism says that a number can be followed by an optional space, so this one is safe. To be sure, of course, one can end the scanning of the ifnum test with relax: ifnum#1=1relax.



          In this particular case, the % wouldn't casuse troubles, but it's probably better to be on the safe side.






          share|improve this answer






















          • maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
            – jfbu
            2 days ago






          • 1




            @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
            – egreg
            yesterday










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            yesterday










          • @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            yesterday










          • +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
            – jfbu
            yesterday














          up vote
          6
          down vote



          accepted










          If you look at the log you'll see that the first thing TeX complains about is:



          ! Illegal parameter number in definition of endletters.
          <to be read again>
          1
          l.22 }


          That's because you tried to use #1 in the end part of the environment, but you can't use the arguments passed to the begin part in the end part of an environment.



          If you were to do that, then the usage of the environment would have to be
          something like this:



          beginletters1
          item stuff
          endletters1


          passing the argument to endletters too.



          To do what you want you need to devise another way to pass that information to the end part. For instance, with a newif:



          documentclassarticle
          usepackageenumitem
          usepackagemulticol

          newififLettersMulticol
          newenvironmentletters[1]%
          vspace-3mm
          ifnum #1=1
          else
          LettersMulticoltrue
          beginmulticols#1
          fi
          beginenumerate[label=textbf(alph*)]
          %
          endenumerate
          ifLettersMulticol
          endmulticols
          fi
          vspace-5mm


          begindocument

          beginletters1
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          beginletters2
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          enddocument



          Also, as it's been noted in the comments, it's not a good idea to add a % at the end of the line in ifnum tests (and a couple other cases too). When TeX is scanning the numbers in the ifnum test, it is expanding tokens, and will continue to do so until something that is not a number is found. For instance, the following (perhaps idiotic, but serves as demonstration) code



          ifnum1=0%
          ifnum2=2
          1%
          else
          2%
          fi
          a%
          else
          b%
          fi


          produces a, instead of b, as someone that took a quick glance at the ifnum1=0 would guess. If, however, you remove the very first %, the output is b.



          Also, a missing % at the end of a ifnum#1=1 test will not appear in the output, because TeX's number scanning mechanism says that a number can be followed by an optional space, so this one is safe. To be sure, of course, one can end the scanning of the ifnum test with relax: ifnum#1=1relax.



          In this particular case, the % wouldn't casuse troubles, but it's probably better to be on the safe side.






          share|improve this answer






















          • maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
            – jfbu
            2 days ago






          • 1




            @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
            – egreg
            yesterday










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            yesterday










          • @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            yesterday










          • +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
            – jfbu
            yesterday












          up vote
          6
          down vote



          accepted







          up vote
          6
          down vote



          accepted






          If you look at the log you'll see that the first thing TeX complains about is:



          ! Illegal parameter number in definition of endletters.
          <to be read again>
          1
          l.22 }


          That's because you tried to use #1 in the end part of the environment, but you can't use the arguments passed to the begin part in the end part of an environment.



          If you were to do that, then the usage of the environment would have to be
          something like this:



          beginletters1
          item stuff
          endletters1


          passing the argument to endletters too.



          To do what you want you need to devise another way to pass that information to the end part. For instance, with a newif:



          documentclassarticle
          usepackageenumitem
          usepackagemulticol

          newififLettersMulticol
          newenvironmentletters[1]%
          vspace-3mm
          ifnum #1=1
          else
          LettersMulticoltrue
          beginmulticols#1
          fi
          beginenumerate[label=textbf(alph*)]
          %
          endenumerate
          ifLettersMulticol
          endmulticols
          fi
          vspace-5mm


          begindocument

          beginletters1
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          beginletters2
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          enddocument



          Also, as it's been noted in the comments, it's not a good idea to add a % at the end of the line in ifnum tests (and a couple other cases too). When TeX is scanning the numbers in the ifnum test, it is expanding tokens, and will continue to do so until something that is not a number is found. For instance, the following (perhaps idiotic, but serves as demonstration) code



          ifnum1=0%
          ifnum2=2
          1%
          else
          2%
          fi
          a%
          else
          b%
          fi


          produces a, instead of b, as someone that took a quick glance at the ifnum1=0 would guess. If, however, you remove the very first %, the output is b.



          Also, a missing % at the end of a ifnum#1=1 test will not appear in the output, because TeX's number scanning mechanism says that a number can be followed by an optional space, so this one is safe. To be sure, of course, one can end the scanning of the ifnum test with relax: ifnum#1=1relax.



          In this particular case, the % wouldn't casuse troubles, but it's probably better to be on the safe side.






          share|improve this answer














          If you look at the log you'll see that the first thing TeX complains about is:



          ! Illegal parameter number in definition of endletters.
          <to be read again>
          1
          l.22 }


          That's because you tried to use #1 in the end part of the environment, but you can't use the arguments passed to the begin part in the end part of an environment.



          If you were to do that, then the usage of the environment would have to be
          something like this:



          beginletters1
          item stuff
          endletters1


          passing the argument to endletters too.



          To do what you want you need to devise another way to pass that information to the end part. For instance, with a newif:



          documentclassarticle
          usepackageenumitem
          usepackagemulticol

          newififLettersMulticol
          newenvironmentletters[1]%
          vspace-3mm
          ifnum #1=1
          else
          LettersMulticoltrue
          beginmulticols#1
          fi
          beginenumerate[label=textbf(alph*)]
          %
          endenumerate
          ifLettersMulticol
          endmulticols
          fi
          vspace-5mm


          begindocument

          beginletters1
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          beginletters2
          item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          item tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
          item quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
          item consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
          item cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
          item proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
          endletters

          enddocument



          Also, as it's been noted in the comments, it's not a good idea to add a % at the end of the line in ifnum tests (and a couple other cases too). When TeX is scanning the numbers in the ifnum test, it is expanding tokens, and will continue to do so until something that is not a number is found. For instance, the following (perhaps idiotic, but serves as demonstration) code



          ifnum1=0%
          ifnum2=2
          1%
          else
          2%
          fi
          a%
          else
          b%
          fi


          produces a, instead of b, as someone that took a quick glance at the ifnum1=0 would guess. If, however, you remove the very first %, the output is b.



          Also, a missing % at the end of a ifnum#1=1 test will not appear in the output, because TeX's number scanning mechanism says that a number can be followed by an optional space, so this one is safe. To be sure, of course, one can end the scanning of the ifnum test with relax: ifnum#1=1relax.



          In this particular case, the % wouldn't casuse troubles, but it's probably better to be on the safe side.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered 2 days ago









          Phelype Oleinik

          20.1k54277




          20.1k54277











          • maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
            – jfbu
            2 days ago






          • 1




            @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
            – egreg
            yesterday










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            yesterday










          • @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            yesterday










          • +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
            – jfbu
            yesterday
















          • maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
            – jfbu
            2 days ago






          • 1




            @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
            – egreg
            yesterday










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            yesterday










          • @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            yesterday










          • +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
            – jfbu
            yesterday















          maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
          – jfbu
          2 days ago




          maybe stress that you correctly removed the 1% and replaced them by 1<end of line space> else the ifnum test won't work correctly (except if one gets lucky).
          – jfbu
          2 days ago




          1




          1




          @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
          – egreg
          yesterday




          @jfbu In this case one is lucky, because else just follows 1 and so TeX knows it has to stop evaluating the number or the conditional would go wrong. Of course a proper constant termination is much better.
          – egreg
          yesterday












          @jfbu Thanks for the reminder. I forgot I changed that :-)
          – Phelype Oleinik
          yesterday




          @jfbu Thanks for the reminder. I forgot I changed that :-)
          – Phelype Oleinik
          yesterday












          @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
          – Phelype Oleinik
          yesterday




          @egreg I agree. The pagenumberinggobble was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
          – Phelype Oleinik
          yesterday












          +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
          – jfbu
          yesterday




          +1 for the added explanation about ifnum and termination of numbers. relax is not an option if you want to maintain expandability, but in 99% of user cases, that is not the goal, so relax. You can also use space. But the most general is numexpr#1relax because it allows for #1 both explicit digit tokens or a TeX count variable. (I think vaguely that @egreg had a non e-TeX trick somewhere recently but I forgot where).
          – jfbu
          yesterday

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460011%2fhow-to-compare-number-from-newenvironment-argument%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown