What does nop mean and how to use it












4















I wonder what does the nop mean, and how does it work? I Googled it but couldn't find a good answer, for example, I found something like:



newcommand{nop}[1]{}


in my .tex file, so what does it mean?










share|improve this question





























    4















    I wonder what does the nop mean, and how does it work? I Googled it but couldn't find a good answer, for example, I found something like:



    newcommand{nop}[1]{}


    in my .tex file, so what does it mean?










    share|improve this question



























      4












      4








      4








      I wonder what does the nop mean, and how does it work? I Googled it but couldn't find a good answer, for example, I found something like:



      newcommand{nop}[1]{}


      in my .tex file, so what does it mean?










      share|improve this question
















      I wonder what does the nop mean, and how does it work? I Googled it but couldn't find a good answer, for example, I found something like:



      newcommand{nop}[1]{}


      in my .tex file, so what does it mean?







      macros






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 16 '13 at 14:34









      Werner

      448k709921697




      448k709921697










      asked Apr 16 '13 at 14:32









      daiyuedaiyue

      2672512




      2672512






















          1 Answer
          1






          active

          oldest

          votes


















          6














          In your example, nop is defined to take a single argument and do nothing with it. As such, nop literally translates to "perform no operation", or "gobble your argument". In fact, there exists a similar core macro @gobble (and friends) which does exactly the same (from latex.ltx:



          longdef @gobble #1{}
          longdef @gobbletwo #1#2{}
          longdef @gobblefour #1#2#3#4{}


          The first gobbles a single argument, making @gobble{<anything>} expand to nothing. The second gobbles two arguments, making @gobbletwo{<anything>}{<anything>} expand to nothing, and so on.



          What's the use case here? Well, perhaps you define a macro that writes something in the margin, like a "to do" note:



          newcommand{mymacro}[1]{marginpar{Do #1}}


          Now, later in your production, you decide that this operation is no longer valid/useful. So, you can make mymacro act like nop and do nothing, which allows you to leave your code as-is:



          letmymacronop


          or, at definition in your preamble, change it to a no-op:



          newcommand{mymacro}[1]{}





          share|improve this answer
























          • another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

            – daiyue
            Apr 16 '13 at 14:46








          • 1





            @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

            – barbara beeton
            Apr 16 '13 at 14:52











          • Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

            – mafp
            Apr 16 '13 at 15:49











          • The nop definition in the question, produces an extra space.

            – ctrl-alt-delor
            Jul 8 '18 at 17:35











          • @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

            – Werner
            Jul 8 '18 at 18:41











          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',
          autoActivateHeartbeat: false,
          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%2f109039%2fwhat-does-nop-mean-and-how-to-use-it%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









          6














          In your example, nop is defined to take a single argument and do nothing with it. As such, nop literally translates to "perform no operation", or "gobble your argument". In fact, there exists a similar core macro @gobble (and friends) which does exactly the same (from latex.ltx:



          longdef @gobble #1{}
          longdef @gobbletwo #1#2{}
          longdef @gobblefour #1#2#3#4{}


          The first gobbles a single argument, making @gobble{<anything>} expand to nothing. The second gobbles two arguments, making @gobbletwo{<anything>}{<anything>} expand to nothing, and so on.



          What's the use case here? Well, perhaps you define a macro that writes something in the margin, like a "to do" note:



          newcommand{mymacro}[1]{marginpar{Do #1}}


          Now, later in your production, you decide that this operation is no longer valid/useful. So, you can make mymacro act like nop and do nothing, which allows you to leave your code as-is:



          letmymacronop


          or, at definition in your preamble, change it to a no-op:



          newcommand{mymacro}[1]{}





          share|improve this answer
























          • another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

            – daiyue
            Apr 16 '13 at 14:46








          • 1





            @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

            – barbara beeton
            Apr 16 '13 at 14:52











          • Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

            – mafp
            Apr 16 '13 at 15:49











          • The nop definition in the question, produces an extra space.

            – ctrl-alt-delor
            Jul 8 '18 at 17:35











          • @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

            – Werner
            Jul 8 '18 at 18:41
















          6














          In your example, nop is defined to take a single argument and do nothing with it. As such, nop literally translates to "perform no operation", or "gobble your argument". In fact, there exists a similar core macro @gobble (and friends) which does exactly the same (from latex.ltx:



          longdef @gobble #1{}
          longdef @gobbletwo #1#2{}
          longdef @gobblefour #1#2#3#4{}


          The first gobbles a single argument, making @gobble{<anything>} expand to nothing. The second gobbles two arguments, making @gobbletwo{<anything>}{<anything>} expand to nothing, and so on.



          What's the use case here? Well, perhaps you define a macro that writes something in the margin, like a "to do" note:



          newcommand{mymacro}[1]{marginpar{Do #1}}


          Now, later in your production, you decide that this operation is no longer valid/useful. So, you can make mymacro act like nop and do nothing, which allows you to leave your code as-is:



          letmymacronop


          or, at definition in your preamble, change it to a no-op:



          newcommand{mymacro}[1]{}





          share|improve this answer
























          • another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

            – daiyue
            Apr 16 '13 at 14:46








          • 1





            @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

            – barbara beeton
            Apr 16 '13 at 14:52











          • Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

            – mafp
            Apr 16 '13 at 15:49











          • The nop definition in the question, produces an extra space.

            – ctrl-alt-delor
            Jul 8 '18 at 17:35











          • @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

            – Werner
            Jul 8 '18 at 18:41














          6












          6








          6







          In your example, nop is defined to take a single argument and do nothing with it. As such, nop literally translates to "perform no operation", or "gobble your argument". In fact, there exists a similar core macro @gobble (and friends) which does exactly the same (from latex.ltx:



          longdef @gobble #1{}
          longdef @gobbletwo #1#2{}
          longdef @gobblefour #1#2#3#4{}


          The first gobbles a single argument, making @gobble{<anything>} expand to nothing. The second gobbles two arguments, making @gobbletwo{<anything>}{<anything>} expand to nothing, and so on.



          What's the use case here? Well, perhaps you define a macro that writes something in the margin, like a "to do" note:



          newcommand{mymacro}[1]{marginpar{Do #1}}


          Now, later in your production, you decide that this operation is no longer valid/useful. So, you can make mymacro act like nop and do nothing, which allows you to leave your code as-is:



          letmymacronop


          or, at definition in your preamble, change it to a no-op:



          newcommand{mymacro}[1]{}





          share|improve this answer













          In your example, nop is defined to take a single argument and do nothing with it. As such, nop literally translates to "perform no operation", or "gobble your argument". In fact, there exists a similar core macro @gobble (and friends) which does exactly the same (from latex.ltx:



          longdef @gobble #1{}
          longdef @gobbletwo #1#2{}
          longdef @gobblefour #1#2#3#4{}


          The first gobbles a single argument, making @gobble{<anything>} expand to nothing. The second gobbles two arguments, making @gobbletwo{<anything>}{<anything>} expand to nothing, and so on.



          What's the use case here? Well, perhaps you define a macro that writes something in the margin, like a "to do" note:



          newcommand{mymacro}[1]{marginpar{Do #1}}


          Now, later in your production, you decide that this operation is no longer valid/useful. So, you can make mymacro act like nop and do nothing, which allows you to leave your code as-is:



          letmymacronop


          or, at definition in your preamble, change it to a no-op:



          newcommand{mymacro}[1]{}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 16 '13 at 14:37









          WernerWerner

          448k709921697




          448k709921697













          • another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

            – daiyue
            Apr 16 '13 at 14:46








          • 1





            @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

            – barbara beeton
            Apr 16 '13 at 14:52











          • Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

            – mafp
            Apr 16 '13 at 15:49











          • The nop definition in the question, produces an extra space.

            – ctrl-alt-delor
            Jul 8 '18 at 17:35











          • @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

            – Werner
            Jul 8 '18 at 18:41



















          • another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

            – daiyue
            Apr 16 '13 at 14:46








          • 1





            @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

            – barbara beeton
            Apr 16 '13 at 14:52











          • Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

            – mafp
            Apr 16 '13 at 15:49











          • The nop definition in the question, produces an extra space.

            – ctrl-alt-delor
            Jul 8 '18 at 17:35











          • @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

            – Werner
            Jul 8 '18 at 18:41

















          another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

          – daiyue
          Apr 16 '13 at 14:46







          another thing that confused me is that any paragraph that is enclosed in this nop{} command using the macro in the example, is disappeared, so i wonder why.

          – daiyue
          Apr 16 '13 at 14:46






          1




          1





          @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

          – barbara beeton
          Apr 16 '13 at 14:52





          @daiyue -- making anything presented as an argument to nop disappear is exactly its purpose.

          – barbara beeton
          Apr 16 '13 at 14:52













          Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

          – mafp
          Apr 16 '13 at 15:49





          Something like nop is also frequently used in conjunction with BibTeX to fix the sorting order.

          – mafp
          Apr 16 '13 at 15:49













          The nop definition in the question, produces an extra space.

          – ctrl-alt-delor
          Jul 8 '18 at 17:35





          The nop definition in the question, produces an extra space.

          – ctrl-alt-delor
          Jul 8 '18 at 17:35













          @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

          – Werner
          Jul 8 '18 at 18:41





          @ctrl-alt-delor: you can add ignorespaces or unskip or use a trailing %.

          – Werner
          Jul 8 '18 at 18:41


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f109039%2fwhat-does-nop-mean-and-how-to-use-it%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

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks