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?
macros lengths
add a comment |
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?
macros lengths
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
add a comment |
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?
macros lengths
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
macros lengths
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
add a comment |
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
add a comment |
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.
Good answer. Note thatsetlength
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
add a comment |
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.
Good answer. Note thatsetlength
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
add a comment |
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.
Good answer. Note thatsetlength
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
add a comment |
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.
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.
edited 10 hours ago
answered 16 hours ago
siracusa
4,76011128
4,76011128
Good answer. Note thatsetlength
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
add a comment |
Good answer. Note thatsetlength
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
add a 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.
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.
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%2f464258%2fwhat-is-the-difference-between-assignment-setlength-and-renewcommand-when-cha%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
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