What does nop mean and how to use it
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
add a comment |
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
add a comment |
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
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
macros
edited Apr 16 '13 at 14:34
Werner
448k709921697
448k709921697
asked Apr 16 '13 at 14:32
daiyuedaiyue
2672512
2672512
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In your example, nop
is defined to take a single argument and do nothing with it. As such, nop
literally translates to "perform n
o op
eration", 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]{}
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 tonop
disappear is exactly its purpose.
– barbara beeton
Apr 16 '13 at 14:52
Something likenop
is also frequently used in conjunction withBibTeX
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 addignorespaces
orunskip
or use a trailing%
.
– Werner
Jul 8 '18 at 18:41
|
show 1 more comment
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
In your example, nop
is defined to take a single argument and do nothing with it. As such, nop
literally translates to "perform n
o op
eration", 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]{}
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 tonop
disappear is exactly its purpose.
– barbara beeton
Apr 16 '13 at 14:52
Something likenop
is also frequently used in conjunction withBibTeX
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 addignorespaces
orunskip
or use a trailing%
.
– Werner
Jul 8 '18 at 18:41
|
show 1 more comment
In your example, nop
is defined to take a single argument and do nothing with it. As such, nop
literally translates to "perform n
o op
eration", 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]{}
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 tonop
disappear is exactly its purpose.
– barbara beeton
Apr 16 '13 at 14:52
Something likenop
is also frequently used in conjunction withBibTeX
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 addignorespaces
orunskip
or use a trailing%
.
– Werner
Jul 8 '18 at 18:41
|
show 1 more comment
In your example, nop
is defined to take a single argument and do nothing with it. As such, nop
literally translates to "perform n
o op
eration", 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]{}
In your example, nop
is defined to take a single argument and do nothing with it. As such, nop
literally translates to "perform n
o op
eration", 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]{}
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 tonop
disappear is exactly its purpose.
– barbara beeton
Apr 16 '13 at 14:52
Something likenop
is also frequently used in conjunction withBibTeX
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 addignorespaces
orunskip
or use a trailing%
.
– Werner
Jul 8 '18 at 18:41
|
show 1 more comment
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 tonop
disappear is exactly its purpose.
– barbara beeton
Apr 16 '13 at 14:52
Something likenop
is also frequently used in conjunction withBibTeX
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 addignorespaces
orunskip
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
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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