Missing number, treated as zero when using renewcommand











up vote
1
down vote

favorite












I am trying to temporarily get read of marginpars in my paper.



I tried to simply renewcommand{marginpar}{} but I get:



! Missing number, treated as zero.<to be read again>} renewcommand{marginpar}{}


I don't know why I am getting this error since it usually compiles my pdf without errors. Do you guys have any idea?



Thanks in advance










share|improve this question






















  • You'll want to try renewcommand{marginpar}[2]{}. The first optional argument gives the number of arguments the (re)defined command has. If there is a second optional argument to (re)newcommand the first argument of the (re)defined command is optional. You may leave out the first optional argument (it is optional after all), but if it is present it must be a number. marginpar has two arguments: An optional one and a mandatory one in that order, hence [2] does what you need.
    – moewe
    14 hours ago












  • tex.stackexchange.com/q/117358/107497 and tex.stackexchange.com/q/280527/107497 are similar questions about newcommand. renewcommand has the same syntax.
    – Teepeemm
    14 hours ago










  • @moewe that did it. Thanks for that. Please post as an answer with the explanations. Will accept right away :)
    – LBes
    14 hours ago















up vote
1
down vote

favorite












I am trying to temporarily get read of marginpars in my paper.



I tried to simply renewcommand{marginpar}{} but I get:



! Missing number, treated as zero.<to be read again>} renewcommand{marginpar}{}


I don't know why I am getting this error since it usually compiles my pdf without errors. Do you guys have any idea?



Thanks in advance










share|improve this question






















  • You'll want to try renewcommand{marginpar}[2]{}. The first optional argument gives the number of arguments the (re)defined command has. If there is a second optional argument to (re)newcommand the first argument of the (re)defined command is optional. You may leave out the first optional argument (it is optional after all), but if it is present it must be a number. marginpar has two arguments: An optional one and a mandatory one in that order, hence [2] does what you need.
    – moewe
    14 hours ago












  • tex.stackexchange.com/q/117358/107497 and tex.stackexchange.com/q/280527/107497 are similar questions about newcommand. renewcommand has the same syntax.
    – Teepeemm
    14 hours ago










  • @moewe that did it. Thanks for that. Please post as an answer with the explanations. Will accept right away :)
    – LBes
    14 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying to temporarily get read of marginpars in my paper.



I tried to simply renewcommand{marginpar}{} but I get:



! Missing number, treated as zero.<to be read again>} renewcommand{marginpar}{}


I don't know why I am getting this error since it usually compiles my pdf without errors. Do you guys have any idea?



Thanks in advance










share|improve this question













I am trying to temporarily get read of marginpars in my paper.



I tried to simply renewcommand{marginpar}{} but I get:



! Missing number, treated as zero.<to be read again>} renewcommand{marginpar}{}


I don't know why I am getting this error since it usually compiles my pdf without errors. Do you guys have any idea?



Thanks in advance







macros margins marginpar






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 14 hours ago









LBes

1086




1086












  • You'll want to try renewcommand{marginpar}[2]{}. The first optional argument gives the number of arguments the (re)defined command has. If there is a second optional argument to (re)newcommand the first argument of the (re)defined command is optional. You may leave out the first optional argument (it is optional after all), but if it is present it must be a number. marginpar has two arguments: An optional one and a mandatory one in that order, hence [2] does what you need.
    – moewe
    14 hours ago












  • tex.stackexchange.com/q/117358/107497 and tex.stackexchange.com/q/280527/107497 are similar questions about newcommand. renewcommand has the same syntax.
    – Teepeemm
    14 hours ago










  • @moewe that did it. Thanks for that. Please post as an answer with the explanations. Will accept right away :)
    – LBes
    14 hours ago


















  • You'll want to try renewcommand{marginpar}[2]{}. The first optional argument gives the number of arguments the (re)defined command has. If there is a second optional argument to (re)newcommand the first argument of the (re)defined command is optional. You may leave out the first optional argument (it is optional after all), but if it is present it must be a number. marginpar has two arguments: An optional one and a mandatory one in that order, hence [2] does what you need.
    – moewe
    14 hours ago












  • tex.stackexchange.com/q/117358/107497 and tex.stackexchange.com/q/280527/107497 are similar questions about newcommand. renewcommand has the same syntax.
    – Teepeemm
    14 hours ago










  • @moewe that did it. Thanks for that. Please post as an answer with the explanations. Will accept right away :)
    – LBes
    14 hours ago
















You'll want to try renewcommand{marginpar}[2]{}. The first optional argument gives the number of arguments the (re)defined command has. If there is a second optional argument to (re)newcommand the first argument of the (re)defined command is optional. You may leave out the first optional argument (it is optional after all), but if it is present it must be a number. marginpar has two arguments: An optional one and a mandatory one in that order, hence [2] does what you need.
– moewe
14 hours ago






You'll want to try renewcommand{marginpar}[2]{}. The first optional argument gives the number of arguments the (re)defined command has. If there is a second optional argument to (re)newcommand the first argument of the (re)defined command is optional. You may leave out the first optional argument (it is optional after all), but if it is present it must be a number. marginpar has two arguments: An optional one and a mandatory one in that order, hence [2] does what you need.
– moewe
14 hours ago














tex.stackexchange.com/q/117358/107497 and tex.stackexchange.com/q/280527/107497 are similar questions about newcommand. renewcommand has the same syntax.
– Teepeemm
14 hours ago




tex.stackexchange.com/q/117358/107497 and tex.stackexchange.com/q/280527/107497 are similar questions about newcommand. renewcommand has the same syntax.
– Teepeemm
14 hours ago












@moewe that did it. Thanks for that. Please post as an answer with the explanations. Will accept right away :)
– LBes
14 hours ago




@moewe that did it. Thanks for that. Please post as an answer with the explanations. Will accept right away :)
– LBes
14 hours ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










In order to get rid of marginpar properly (assuming its usual definition) you will want to try



renewcommand{marginpar}[2]{}


The exact syntax of (re)newcommand has been explained elsewhere (for example in newcommand argument confusion) far better than I could, so let me just recap shortly that the usual syntax for (re)newcommand is



newcommand{<command>}[<number of arguments>][<optional value>]{<definition>}


where the both arguments in square brackets are optional - if there is only one optional argument it is interpreted as the first optional argument.



<number of arguments> gives the number of arguments <command> accepts and must be a number if it is present. That is what caused the error in your example, it is not acceptable to leave the square brackets empty. If additional <optional value> is present, the first argument of <command> becomes optional and is assumed to be <optional value> if it is not present (optional arguments are commonly given in square brackets, mandatory arguments in curly brackets).



This means that commands defined with (re)newcommand will always have one of the following argument structures



foo                    % no argument at all
foo{m_1} % one mandatory argument
foo[o_1] % one optional argument
foo{m_1}{m_2}...{m_n} % n leq 9, two to nine mandatory arguments
foo[o_1]{m_1}...{m_n} % n leq 8, one optional argument and one to eight mandatory arguments


Other argument structures are possible in (La)TeX, but they have to be coded differently. Ironically, newcommand itself uses a very different structure.



marginpar has the following argument specification



marginpar[<LTEXT>]{<RTEXT>}


which means that its structure can be redefined with renewcommand directly as a macro with two arguments of which the first is optional.





Ulrich Diez made a good point in the comments that one needs to be careful about the spacing. The default definition of marginpar uses @bsphack...@esphack to avoid unwanted white space, see How to make a command completely empty / invisible / non-existent?. If you want to replicate that behaviour to not change spacing when you disable marginpar, you'll need the more involved



makeatletter
renewcommand{marginpar}[2]{@bsphack@esphack}
makeatother


Whether or not that is necessary will depend on how exactly you used marginpar and what your requirements and intentions are for disabling it. If it's just for a quick test you needn't bother, if it's for the final print version that's a different matter.






share|improve this answer























  • Thanks for the recap. Very nice answer. Answer accepted!
    – LBes
    13 hours ago










  • @UlrichDiez Ah yes, thanks for the hint. Added a short edit.
    – moewe
    9 hours ago











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%2f461149%2fmissing-number-treated-as-zero-when-using-renewcommand%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
2
down vote



accepted










In order to get rid of marginpar properly (assuming its usual definition) you will want to try



renewcommand{marginpar}[2]{}


The exact syntax of (re)newcommand has been explained elsewhere (for example in newcommand argument confusion) far better than I could, so let me just recap shortly that the usual syntax for (re)newcommand is



newcommand{<command>}[<number of arguments>][<optional value>]{<definition>}


where the both arguments in square brackets are optional - if there is only one optional argument it is interpreted as the first optional argument.



<number of arguments> gives the number of arguments <command> accepts and must be a number if it is present. That is what caused the error in your example, it is not acceptable to leave the square brackets empty. If additional <optional value> is present, the first argument of <command> becomes optional and is assumed to be <optional value> if it is not present (optional arguments are commonly given in square brackets, mandatory arguments in curly brackets).



This means that commands defined with (re)newcommand will always have one of the following argument structures



foo                    % no argument at all
foo{m_1} % one mandatory argument
foo[o_1] % one optional argument
foo{m_1}{m_2}...{m_n} % n leq 9, two to nine mandatory arguments
foo[o_1]{m_1}...{m_n} % n leq 8, one optional argument and one to eight mandatory arguments


Other argument structures are possible in (La)TeX, but they have to be coded differently. Ironically, newcommand itself uses a very different structure.



marginpar has the following argument specification



marginpar[<LTEXT>]{<RTEXT>}


which means that its structure can be redefined with renewcommand directly as a macro with two arguments of which the first is optional.





Ulrich Diez made a good point in the comments that one needs to be careful about the spacing. The default definition of marginpar uses @bsphack...@esphack to avoid unwanted white space, see How to make a command completely empty / invisible / non-existent?. If you want to replicate that behaviour to not change spacing when you disable marginpar, you'll need the more involved



makeatletter
renewcommand{marginpar}[2]{@bsphack@esphack}
makeatother


Whether or not that is necessary will depend on how exactly you used marginpar and what your requirements and intentions are for disabling it. If it's just for a quick test you needn't bother, if it's for the final print version that's a different matter.






share|improve this answer























  • Thanks for the recap. Very nice answer. Answer accepted!
    – LBes
    13 hours ago










  • @UlrichDiez Ah yes, thanks for the hint. Added a short edit.
    – moewe
    9 hours ago















up vote
2
down vote



accepted










In order to get rid of marginpar properly (assuming its usual definition) you will want to try



renewcommand{marginpar}[2]{}


The exact syntax of (re)newcommand has been explained elsewhere (for example in newcommand argument confusion) far better than I could, so let me just recap shortly that the usual syntax for (re)newcommand is



newcommand{<command>}[<number of arguments>][<optional value>]{<definition>}


where the both arguments in square brackets are optional - if there is only one optional argument it is interpreted as the first optional argument.



<number of arguments> gives the number of arguments <command> accepts and must be a number if it is present. That is what caused the error in your example, it is not acceptable to leave the square brackets empty. If additional <optional value> is present, the first argument of <command> becomes optional and is assumed to be <optional value> if it is not present (optional arguments are commonly given in square brackets, mandatory arguments in curly brackets).



This means that commands defined with (re)newcommand will always have one of the following argument structures



foo                    % no argument at all
foo{m_1} % one mandatory argument
foo[o_1] % one optional argument
foo{m_1}{m_2}...{m_n} % n leq 9, two to nine mandatory arguments
foo[o_1]{m_1}...{m_n} % n leq 8, one optional argument and one to eight mandatory arguments


Other argument structures are possible in (La)TeX, but they have to be coded differently. Ironically, newcommand itself uses a very different structure.



marginpar has the following argument specification



marginpar[<LTEXT>]{<RTEXT>}


which means that its structure can be redefined with renewcommand directly as a macro with two arguments of which the first is optional.





Ulrich Diez made a good point in the comments that one needs to be careful about the spacing. The default definition of marginpar uses @bsphack...@esphack to avoid unwanted white space, see How to make a command completely empty / invisible / non-existent?. If you want to replicate that behaviour to not change spacing when you disable marginpar, you'll need the more involved



makeatletter
renewcommand{marginpar}[2]{@bsphack@esphack}
makeatother


Whether or not that is necessary will depend on how exactly you used marginpar and what your requirements and intentions are for disabling it. If it's just for a quick test you needn't bother, if it's for the final print version that's a different matter.






share|improve this answer























  • Thanks for the recap. Very nice answer. Answer accepted!
    – LBes
    13 hours ago










  • @UlrichDiez Ah yes, thanks for the hint. Added a short edit.
    – moewe
    9 hours ago













up vote
2
down vote



accepted







up vote
2
down vote



accepted






In order to get rid of marginpar properly (assuming its usual definition) you will want to try



renewcommand{marginpar}[2]{}


The exact syntax of (re)newcommand has been explained elsewhere (for example in newcommand argument confusion) far better than I could, so let me just recap shortly that the usual syntax for (re)newcommand is



newcommand{<command>}[<number of arguments>][<optional value>]{<definition>}


where the both arguments in square brackets are optional - if there is only one optional argument it is interpreted as the first optional argument.



<number of arguments> gives the number of arguments <command> accepts and must be a number if it is present. That is what caused the error in your example, it is not acceptable to leave the square brackets empty. If additional <optional value> is present, the first argument of <command> becomes optional and is assumed to be <optional value> if it is not present (optional arguments are commonly given in square brackets, mandatory arguments in curly brackets).



This means that commands defined with (re)newcommand will always have one of the following argument structures



foo                    % no argument at all
foo{m_1} % one mandatory argument
foo[o_1] % one optional argument
foo{m_1}{m_2}...{m_n} % n leq 9, two to nine mandatory arguments
foo[o_1]{m_1}...{m_n} % n leq 8, one optional argument and one to eight mandatory arguments


Other argument structures are possible in (La)TeX, but they have to be coded differently. Ironically, newcommand itself uses a very different structure.



marginpar has the following argument specification



marginpar[<LTEXT>]{<RTEXT>}


which means that its structure can be redefined with renewcommand directly as a macro with two arguments of which the first is optional.





Ulrich Diez made a good point in the comments that one needs to be careful about the spacing. The default definition of marginpar uses @bsphack...@esphack to avoid unwanted white space, see How to make a command completely empty / invisible / non-existent?. If you want to replicate that behaviour to not change spacing when you disable marginpar, you'll need the more involved



makeatletter
renewcommand{marginpar}[2]{@bsphack@esphack}
makeatother


Whether or not that is necessary will depend on how exactly you used marginpar and what your requirements and intentions are for disabling it. If it's just for a quick test you needn't bother, if it's for the final print version that's a different matter.






share|improve this answer














In order to get rid of marginpar properly (assuming its usual definition) you will want to try



renewcommand{marginpar}[2]{}


The exact syntax of (re)newcommand has been explained elsewhere (for example in newcommand argument confusion) far better than I could, so let me just recap shortly that the usual syntax for (re)newcommand is



newcommand{<command>}[<number of arguments>][<optional value>]{<definition>}


where the both arguments in square brackets are optional - if there is only one optional argument it is interpreted as the first optional argument.



<number of arguments> gives the number of arguments <command> accepts and must be a number if it is present. That is what caused the error in your example, it is not acceptable to leave the square brackets empty. If additional <optional value> is present, the first argument of <command> becomes optional and is assumed to be <optional value> if it is not present (optional arguments are commonly given in square brackets, mandatory arguments in curly brackets).



This means that commands defined with (re)newcommand will always have one of the following argument structures



foo                    % no argument at all
foo{m_1} % one mandatory argument
foo[o_1] % one optional argument
foo{m_1}{m_2}...{m_n} % n leq 9, two to nine mandatory arguments
foo[o_1]{m_1}...{m_n} % n leq 8, one optional argument and one to eight mandatory arguments


Other argument structures are possible in (La)TeX, but they have to be coded differently. Ironically, newcommand itself uses a very different structure.



marginpar has the following argument specification



marginpar[<LTEXT>]{<RTEXT>}


which means that its structure can be redefined with renewcommand directly as a macro with two arguments of which the first is optional.





Ulrich Diez made a good point in the comments that one needs to be careful about the spacing. The default definition of marginpar uses @bsphack...@esphack to avoid unwanted white space, see How to make a command completely empty / invisible / non-existent?. If you want to replicate that behaviour to not change spacing when you disable marginpar, you'll need the more involved



makeatletter
renewcommand{marginpar}[2]{@bsphack@esphack}
makeatother


Whether or not that is necessary will depend on how exactly you used marginpar and what your requirements and intentions are for disabling it. If it's just for a quick test you needn't bother, if it's for the final print version that's a different matter.







share|improve this answer














share|improve this answer



share|improve this answer








edited 9 hours ago

























answered 13 hours ago









moewe

82.8k8106317




82.8k8106317












  • Thanks for the recap. Very nice answer. Answer accepted!
    – LBes
    13 hours ago










  • @UlrichDiez Ah yes, thanks for the hint. Added a short edit.
    – moewe
    9 hours ago


















  • Thanks for the recap. Very nice answer. Answer accepted!
    – LBes
    13 hours ago










  • @UlrichDiez Ah yes, thanks for the hint. Added a short edit.
    – moewe
    9 hours ago
















Thanks for the recap. Very nice answer. Answer accepted!
– LBes
13 hours ago




Thanks for the recap. Very nice answer. Answer accepted!
– LBes
13 hours ago












@UlrichDiez Ah yes, thanks for the hint. Added a short edit.
– moewe
9 hours ago




@UlrichDiez Ah yes, thanks for the hint. Added a short edit.
– moewe
9 hours ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461149%2fmissing-number-treated-as-zero-when-using-renewcommand%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

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

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)