How to compare number from newenvironment argument











up vote
6
down vote

favorite












I am trying to create a new environment as follows



newenvironment{letters}[1]{%
vspace{-3mm}
ifnum #1=1%
else
begin{multicols}{#1}
fi
begin{enumerate}[label=textbf{(alph*)}]
}{%
end{enumerate}
ifnum #1=1%
else
end{multicols}
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



    newenvironment{letters}[1]{%
    vspace{-3mm}
    ifnum #1=1%
    else
    begin{multicols}{#1}
    fi
    begin{enumerate}[label=textbf{(alph*)}]
    }{%
    end{enumerate}
    ifnum #1=1%
    else
    end{multicols}
    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



      newenvironment{letters}[1]{%
      vspace{-3mm}
      ifnum #1=1%
      else
      begin{multicols}{#1}
      fi
      begin{enumerate}[label=textbf{(alph*)}]
      }{%
      end{enumerate}
      ifnum #1=1%
      else
      end{multicols}
      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



      newenvironment{letters}[1]{%
      vspace{-3mm}
      ifnum #1=1%
      else
      begin{multicols}{#1}
      fi
      begin{enumerate}[label=textbf{(alph*)}]
      }{%
      end{enumerate}
      ifnum #1=1%
      else
      end{multicols}
      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 Nov 14 at 20:20









      Brasil

      340312




      340312






















          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:



          begin{letters}{1}
          item stuff
          end{letters}{1}


          passing the argument to end{letters} 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:



          documentclass{article}
          usepackage{enumitem}
          usepackage{multicol}

          newififLettersMulticol
          newenvironment{letters}[1]{%
          vspace{-3mm}
          ifnum #1=1
          else
          LettersMulticoltrue
          begin{multicols}{#1}
          fi
          begin{enumerate}[label=textbf{(alph*)}]
          }{%
          end{enumerate}
          ifLettersMulticol
          end{multicols}
          fi
          vspace{-5mm}
          }

          begin{document}

          begin{letters}{1}
          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.
          end{letters}

          begin{letters}{2}
          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.
          end{letters}

          end{document}




          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
            Nov 14 at 21:26






          • 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
            Nov 14 at 21:45










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            Nov 14 at 23:10










          • @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            Nov 14 at 23:12










          • +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
            Nov 15 at 8:04











          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:



          begin{letters}{1}
          item stuff
          end{letters}{1}


          passing the argument to end{letters} 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:



          documentclass{article}
          usepackage{enumitem}
          usepackage{multicol}

          newififLettersMulticol
          newenvironment{letters}[1]{%
          vspace{-3mm}
          ifnum #1=1
          else
          LettersMulticoltrue
          begin{multicols}{#1}
          fi
          begin{enumerate}[label=textbf{(alph*)}]
          }{%
          end{enumerate}
          ifLettersMulticol
          end{multicols}
          fi
          vspace{-5mm}
          }

          begin{document}

          begin{letters}{1}
          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.
          end{letters}

          begin{letters}{2}
          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.
          end{letters}

          end{document}




          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
            Nov 14 at 21:26






          • 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
            Nov 14 at 21:45










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            Nov 14 at 23:10










          • @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            Nov 14 at 23:12










          • +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
            Nov 15 at 8:04















          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:



          begin{letters}{1}
          item stuff
          end{letters}{1}


          passing the argument to end{letters} 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:



          documentclass{article}
          usepackage{enumitem}
          usepackage{multicol}

          newififLettersMulticol
          newenvironment{letters}[1]{%
          vspace{-3mm}
          ifnum #1=1
          else
          LettersMulticoltrue
          begin{multicols}{#1}
          fi
          begin{enumerate}[label=textbf{(alph*)}]
          }{%
          end{enumerate}
          ifLettersMulticol
          end{multicols}
          fi
          vspace{-5mm}
          }

          begin{document}

          begin{letters}{1}
          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.
          end{letters}

          begin{letters}{2}
          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.
          end{letters}

          end{document}




          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
            Nov 14 at 21:26






          • 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
            Nov 14 at 21:45










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            Nov 14 at 23:10










          • @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            Nov 14 at 23:12










          • +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
            Nov 15 at 8:04













          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:



          begin{letters}{1}
          item stuff
          end{letters}{1}


          passing the argument to end{letters} 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:



          documentclass{article}
          usepackage{enumitem}
          usepackage{multicol}

          newififLettersMulticol
          newenvironment{letters}[1]{%
          vspace{-3mm}
          ifnum #1=1
          else
          LettersMulticoltrue
          begin{multicols}{#1}
          fi
          begin{enumerate}[label=textbf{(alph*)}]
          }{%
          end{enumerate}
          ifLettersMulticol
          end{multicols}
          fi
          vspace{-5mm}
          }

          begin{document}

          begin{letters}{1}
          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.
          end{letters}

          begin{letters}{2}
          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.
          end{letters}

          end{document}




          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:



          begin{letters}{1}
          item stuff
          end{letters}{1}


          passing the argument to end{letters} 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:



          documentclass{article}
          usepackage{enumitem}
          usepackage{multicol}

          newififLettersMulticol
          newenvironment{letters}[1]{%
          vspace{-3mm}
          ifnum #1=1
          else
          LettersMulticoltrue
          begin{multicols}{#1}
          fi
          begin{enumerate}[label=textbf{(alph*)}]
          }{%
          end{enumerate}
          ifLettersMulticol
          end{multicols}
          fi
          vspace{-5mm}
          }

          begin{document}

          begin{letters}{1}
          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.
          end{letters}

          begin{letters}{2}
          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.
          end{letters}

          end{document}




          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 Nov 14 at 23:08

























          answered Nov 14 at 20:28









          Phelype Oleinik

          20.4k54277




          20.4k54277












          • 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
            Nov 14 at 21:26






          • 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
            Nov 14 at 21:45










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            Nov 14 at 23:10










          • @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            Nov 14 at 23:12










          • +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
            Nov 15 at 8:04


















          • 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
            Nov 14 at 21:26






          • 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
            Nov 14 at 21:45










          • @jfbu Thanks for the reminder. I forgot I changed that :-)
            – Phelype Oleinik
            Nov 14 at 23:10










          • @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
            – Phelype Oleinik
            Nov 14 at 23:12










          • +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
            Nov 15 at 8:04
















          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
          Nov 14 at 21:26




          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
          Nov 14 at 21:26




          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
          Nov 14 at 21:45




          @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
          Nov 14 at 21:45












          @jfbu Thanks for the reminder. I forgot I changed that :-)
          – Phelype Oleinik
          Nov 14 at 23:10




          @jfbu Thanks for the reminder. I forgot I changed that :-)
          – Phelype Oleinik
          Nov 14 at 23:10












          @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
          – Phelype Oleinik
          Nov 14 at 23:12




          @egreg I agree. The pagenumbering{gobble} was there because I forgot to remove it from another code, sorry for the noise. Thanks :-)
          – Phelype Oleinik
          Nov 14 at 23:12












          +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
          Nov 15 at 8:04




          +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
          Nov 15 at 8:04


















           

          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







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents