What is the difference between assignment, setlength and renewcommand when changing a variable?











up vote
3
down vote

favorite












I want to set the extrarowheight to 0.5ex. I find the following three ways are all applicable.



extrarowheight = 0.5ex
setlength{extrarowheight}{0.5ex}
renewcommand{extrarowheight}{0.5ex}


Just out of curiosity, which way is the canonical one?










share|improve this question
























  • One is setting it the tex way, one is using the latex way, one is more or less just wrong.
    – Johannes_B
    18 hours ago















up vote
3
down vote

favorite












I want to set the extrarowheight to 0.5ex. I find the following three ways are all applicable.



extrarowheight = 0.5ex
setlength{extrarowheight}{0.5ex}
renewcommand{extrarowheight}{0.5ex}


Just out of curiosity, which way is the canonical one?










share|improve this question
























  • One is setting it the tex way, one is using the latex way, one is more or less just wrong.
    – Johannes_B
    18 hours ago













up vote
3
down vote

favorite









up vote
3
down vote

favorite











I want to set the extrarowheight to 0.5ex. I find the following three ways are all applicable.



extrarowheight = 0.5ex
setlength{extrarowheight}{0.5ex}
renewcommand{extrarowheight}{0.5ex}


Just out of curiosity, which way is the canonical one?










share|improve this question















I want to set the extrarowheight to 0.5ex. I find the following three ways are all applicable.



extrarowheight = 0.5ex
setlength{extrarowheight}{0.5ex}
renewcommand{extrarowheight}{0.5ex}


Just out of curiosity, which way is the canonical one?







macros lengths






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 10 hours ago









Martin Scharrer

197k45631813




197k45631813










asked 18 hours ago









Eli4ph

637




637












  • One is setting it the tex way, one is using the latex way, one is more or less just wrong.
    – Johannes_B
    18 hours ago


















  • One is setting it the tex way, one is using the latex way, one is more or less just wrong.
    – Johannes_B
    18 hours ago
















One is setting it the tex way, one is using the latex way, one is more or less just wrong.
– Johannes_B
18 hours ago




One is setting it the tex way, one is using the latex way, one is more or less just wrong.
– Johannes_B
18 hours ago










1 Answer
1






active

oldest

votes

















up vote
6
down vote













As mentioned in the comments, the first version is the TeX version of assignments, the second version is the LaTeX version of assigning values to variables. Both usually yield the same result, as the second one is based on the first.



The second version is less error-prone, though, because it's equivalent to extrarowheight=0.5exrelax which prevents the parser from accidentally mistaking extra characters after the assignment to be part of the new value.



Note however, that the third version is not equivalent to the other two, and wrong in that sense. It doesn't do a variable assignment but redefines extrarowheight to be a macro which expands to the token sequence 0.5ex. You can see the difference when you try the following:



setlength{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=dimen104.




while



renewcommand{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=long macro:
->0.5ex.




In some cases the use of that macro will still yield the same result as the use of the variable, but as soon as you try to set the variable the correct way, the problem becomes apparent:



renewcommand{extrarowheight}{0.5ex}
setlength{extrarowheight}{1.0ex}


prints 0.5ex1.0ex instead of doing an assignment.






share|improve this answer























  • Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
    – Martin Scharrer
    16 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%2f464258%2fwhat-is-the-difference-between-assignment-setlength-and-renewcommand-when-cha%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













As mentioned in the comments, the first version is the TeX version of assignments, the second version is the LaTeX version of assigning values to variables. Both usually yield the same result, as the second one is based on the first.



The second version is less error-prone, though, because it's equivalent to extrarowheight=0.5exrelax which prevents the parser from accidentally mistaking extra characters after the assignment to be part of the new value.



Note however, that the third version is not equivalent to the other two, and wrong in that sense. It doesn't do a variable assignment but redefines extrarowheight to be a macro which expands to the token sequence 0.5ex. You can see the difference when you try the following:



setlength{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=dimen104.




while



renewcommand{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=long macro:
->0.5ex.




In some cases the use of that macro will still yield the same result as the use of the variable, but as soon as you try to set the variable the correct way, the problem becomes apparent:



renewcommand{extrarowheight}{0.5ex}
setlength{extrarowheight}{1.0ex}


prints 0.5ex1.0ex instead of doing an assignment.






share|improve this answer























  • Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
    – Martin Scharrer
    16 hours ago

















up vote
6
down vote













As mentioned in the comments, the first version is the TeX version of assignments, the second version is the LaTeX version of assigning values to variables. Both usually yield the same result, as the second one is based on the first.



The second version is less error-prone, though, because it's equivalent to extrarowheight=0.5exrelax which prevents the parser from accidentally mistaking extra characters after the assignment to be part of the new value.



Note however, that the third version is not equivalent to the other two, and wrong in that sense. It doesn't do a variable assignment but redefines extrarowheight to be a macro which expands to the token sequence 0.5ex. You can see the difference when you try the following:



setlength{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=dimen104.




while



renewcommand{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=long macro:
->0.5ex.




In some cases the use of that macro will still yield the same result as the use of the variable, but as soon as you try to set the variable the correct way, the problem becomes apparent:



renewcommand{extrarowheight}{0.5ex}
setlength{extrarowheight}{1.0ex}


prints 0.5ex1.0ex instead of doing an assignment.






share|improve this answer























  • Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
    – Martin Scharrer
    16 hours ago















up vote
6
down vote










up vote
6
down vote









As mentioned in the comments, the first version is the TeX version of assignments, the second version is the LaTeX version of assigning values to variables. Both usually yield the same result, as the second one is based on the first.



The second version is less error-prone, though, because it's equivalent to extrarowheight=0.5exrelax which prevents the parser from accidentally mistaking extra characters after the assignment to be part of the new value.



Note however, that the third version is not equivalent to the other two, and wrong in that sense. It doesn't do a variable assignment but redefines extrarowheight to be a macro which expands to the token sequence 0.5ex. You can see the difference when you try the following:



setlength{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=dimen104.




while



renewcommand{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=long macro:
->0.5ex.




In some cases the use of that macro will still yield the same result as the use of the variable, but as soon as you try to set the variable the correct way, the problem becomes apparent:



renewcommand{extrarowheight}{0.5ex}
setlength{extrarowheight}{1.0ex}


prints 0.5ex1.0ex instead of doing an assignment.






share|improve this answer














As mentioned in the comments, the first version is the TeX version of assignments, the second version is the LaTeX version of assigning values to variables. Both usually yield the same result, as the second one is based on the first.



The second version is less error-prone, though, because it's equivalent to extrarowheight=0.5exrelax which prevents the parser from accidentally mistaking extra characters after the assignment to be part of the new value.



Note however, that the third version is not equivalent to the other two, and wrong in that sense. It doesn't do a variable assignment but redefines extrarowheight to be a macro which expands to the token sequence 0.5ex. You can see the difference when you try the following:



setlength{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=dimen104.




while



renewcommand{extrarowheight}{0.5ex}
showextrarowheight


outputs




extrarowheight=long macro:
->0.5ex.




In some cases the use of that macro will still yield the same result as the use of the variable, but as soon as you try to set the variable the correct way, the problem becomes apparent:



renewcommand{extrarowheight}{0.5ex}
setlength{extrarowheight}{1.0ex}


prints 0.5ex1.0ex instead of doing an assignment.







share|improve this answer














share|improve this answer



share|improve this answer








edited 10 hours ago

























answered 16 hours ago









siracusa

4,76011128




4,76011128












  • Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
    – Martin Scharrer
    16 hours ago




















  • Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
    – Martin Scharrer
    16 hours ago


















Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
– Martin Scharrer
16 hours ago






Good answer. Note that setlength and others can be extended by package like calc to handle simple equations, e.g. setlength{somelength}{baselineskip + .5ex}. Then it is not equivialent to the TeX assignment anymore.
– Martin Scharrer
16 hours ago




















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f464258%2fwhat-is-the-difference-between-assignment-setlength-and-renewcommand-when-cha%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

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei