the vs. value: what is the differenceThe the commandWhat is the difference between let and def?What is the...
How do you handle simultaneous damage when one type is absorbed and not the other?
Find number 8 with the least number of tries
When to use the gestalt principle of common region?
Why isn't Hagrid removed from Hogwarts sooner in Harry's would-be 7th year?
Translation of: 美しいと思ってしまったのだ
What is the design rationale for having armor and magic penetration mechanics?
I am often given, occasionally stolen, rarely sold, and never borrowed
Easy way of generating a 50-150W load @12V
If we should encrypt the message rather than the method of transfer, why do we care about wifi security? Is this just security theatre?
Mapping string into integers
Usefulness of Nash embedding theorem
Are there 99 percentiles, or 100 percentiles? And are they groups of numbers, or dividers or pointers to individual numbers?
Decrypting Multi-Prime RSA with e, N, and factors of N given
Symbolise polygon outline where it doesn't coincide with other feature using geometry generator in QGIS?
Should I avoid "big words" when writing to a younger audience?
Code Golf Measurer © 2019
Trade a bishop in the opening
What is a "G.O.A.T" game?
How can I communicate feelings to players without impacting their agency?
Can you use a virtual credit card to withdraw money from an ATM in the UK?
How to treat unhandled exceptions? (Terminate the application vs. Keep it alive)
Tikz node without text
Advisor asked for my entire slide presentation so she could give the presentation at an international conference
This is a Noteworthy Riddle
the vs. value: what is the difference
The the commandWhat is the difference between let and def?What is the proper method of accessing a counter?How can I calculate the difference of 2 counters (pageref)?How to store a counter value at some point in the document?How can I test the value of two counters?What's the difference between counters and registers in TeX?Use counters value after it appears in the codeWhat is the difference between badness and penalty?Why does one get the wrong value when printing counters together?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}
I would like to understand the difference between the and value{}
when using counters in LaTeX.
tex-core counters
add a comment
|
I would like to understand the difference between the and value{}
when using counters in LaTeX.
tex-core counters
Related: Thethecommand
– Werner
8 hours ago
add a comment
|
I would like to understand the difference between the and value{}
when using counters in LaTeX.
tex-core counters
I would like to understand the difference between the and value{}
when using counters in LaTeX.
tex-core counters
tex-core counters
edited 8 hours ago
Joseph Wright♦
212k24 gold badges576 silver badges908 bronze badges
212k24 gold badges576 silver badges908 bronze badges
asked 9 hours ago
user2925716user2925716
4151 silver badge7 bronze badges
4151 silver badge7 bronze badges
Related: Thethecommand
– Werner
8 hours ago
add a comment
|
Related: Thethecommand
– Werner
8 hours ago
Related: The
the command– Werner
8 hours ago
Related: The
the command– Werner
8 hours ago
add a comment
|
2 Answers
2
active
oldest
votes
thecounter typesets the result of the counter, be it in arabic, roman, etc, while value{counter} provides an integer value in return. In many, but not all, instances, the difference will go unnoticed.
The rule is, if you are looking for a character, use the...; if you are looking for an integer, use value{...}.
Here's an example where it matters. By typesetting the page number in roman (via pagenumbering{roman}), the option of romannumeralthepage is no longer an option, since it would be attempting romannumeral i, whereas romannumeralvalue{page} works fine.
documentclass{article}
pagenumbering{roman}
begin{document}
romannumeralvalue{page}
% romannumeralthepage will break
end{document}
Here's another example...you cannot typeset value
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%value{Q} will break
theQ
end{document}
The difference can also affect comparisons, since if compares tokens, not integers:
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
ifvalue{Q}2 Telse Ffi is false
iftheQ2 Telse Ffi is true
end{document}
The above example would show a match, were the ifs changed to ifnums, since ifnum will interpret/convert the character 2 into an integer. However, even that can get you into trouble for more complex cases.
Here, I can combine theQ with 3 to represent 23. The same does not apply for value{Q}3.
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%ifnumvalue{Q}3=23 Telse Ffi will break
ifnumtheQ3=23 Telse Ffi is true
end{document}
@user2925716ifnum <condition> <true code>else <false code>fiis TeX's way to perform integer comparisons, where the condition includes an=, a<or a>. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of23. If so it outputsT, if not anFis output. In the case ofvalue{Q}3, the test breaks, becausevalue{Q}3cannot be interpreted as a valid integer.
– Steven B. Segletes
8 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:if T jfiWhy?
– user2925716
7 hours ago
@user2925716 The commandif T jfiwill never print anything.ifcompares the next two fully expanded tokens. In this case, it compares if the tokenTis the same as the space token. If that were true, it prints out aT. No false instruction is given
– Steven B. Segletes
7 hours ago
|
show 5 more comments
This is an interesting mathematical question. The number two hundred seventy-five can be represented in different ways:
- 275 in decimal notation with “Western digits”,
- ٢٧٥ in decimal notation with “Arabic digits”,
- CCLXXV in Roman numerals,
- 113 in hexadecimal digits,
- 100010011 in binary digits,
and many others (it's duecentosettantacinque in Italian).
When you define a new counter in LaTeX, with newcounter{foo}, also the command thefoo is defined, which will expand to a representation of the value stored in the counter; the command is initialized to provide the decimal representation of the counter, but one can say
renewcommand{thefoo}{roman{foo}}
and thereupon, calling thefoo when the counter stores the number 275 will produce
cclxxv
(after macro expansion). The initial definition is essentially equivalent to
newcommand{thefoo}{arabic{foo}}
A common case is the counter page: in the class book, the counter's representation uses roman in the front matter and arabic in the main matter and back matter.
However, the number stored in foo is indepedent of its representation: in some sense, the counter stores the abstract number, something not especially tied to a representation thereof. This abstract value is accessed to by value{foo}.
Let's say you have an application where a counter is bound to contain only the values from 0 to 3 and you want to represent these values with non numerical objects; you can define, for instance,
renewcommand{thefoo}{%
ifcasevalue{foo}%
apple% case 0
or
orange% case 1
or
apricot% case 2
or
strawberry% case 3
else
bummer% wrong setting found
fi
}
The conditional ifcase branches according to the number following it, in this case the abstract value stored in the counter.
You cannot say value{foo} in the document in order to print the value, because the abstract number can only be represented in some way and you have to specify which one. Instead, when TeX is looking for a number (such as after ifcase), then value{foo} is the right code to use.
The objection “but we could use arabic{foo} instead of value{foo}” is dismissed. You really want the abstract number there, not some representation thereof.
add a 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/4.0/"u003ecc by-sa 4.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%2f511435%2fthe-vs-value-what-is-the-difference%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
thecounter typesets the result of the counter, be it in arabic, roman, etc, while value{counter} provides an integer value in return. In many, but not all, instances, the difference will go unnoticed.
The rule is, if you are looking for a character, use the...; if you are looking for an integer, use value{...}.
Here's an example where it matters. By typesetting the page number in roman (via pagenumbering{roman}), the option of romannumeralthepage is no longer an option, since it would be attempting romannumeral i, whereas romannumeralvalue{page} works fine.
documentclass{article}
pagenumbering{roman}
begin{document}
romannumeralvalue{page}
% romannumeralthepage will break
end{document}
Here's another example...you cannot typeset value
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%value{Q} will break
theQ
end{document}
The difference can also affect comparisons, since if compares tokens, not integers:
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
ifvalue{Q}2 Telse Ffi is false
iftheQ2 Telse Ffi is true
end{document}
The above example would show a match, were the ifs changed to ifnums, since ifnum will interpret/convert the character 2 into an integer. However, even that can get you into trouble for more complex cases.
Here, I can combine theQ with 3 to represent 23. The same does not apply for value{Q}3.
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%ifnumvalue{Q}3=23 Telse Ffi will break
ifnumtheQ3=23 Telse Ffi is true
end{document}
@user2925716ifnum <condition> <true code>else <false code>fiis TeX's way to perform integer comparisons, where the condition includes an=, a<or a>. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of23. If so it outputsT, if not anFis output. In the case ofvalue{Q}3, the test breaks, becausevalue{Q}3cannot be interpreted as a valid integer.
– Steven B. Segletes
8 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:if T jfiWhy?
– user2925716
7 hours ago
@user2925716 The commandif T jfiwill never print anything.ifcompares the next two fully expanded tokens. In this case, it compares if the tokenTis the same as the space token. If that were true, it prints out aT. No false instruction is given
– Steven B. Segletes
7 hours ago
|
show 5 more comments
thecounter typesets the result of the counter, be it in arabic, roman, etc, while value{counter} provides an integer value in return. In many, but not all, instances, the difference will go unnoticed.
The rule is, if you are looking for a character, use the...; if you are looking for an integer, use value{...}.
Here's an example where it matters. By typesetting the page number in roman (via pagenumbering{roman}), the option of romannumeralthepage is no longer an option, since it would be attempting romannumeral i, whereas romannumeralvalue{page} works fine.
documentclass{article}
pagenumbering{roman}
begin{document}
romannumeralvalue{page}
% romannumeralthepage will break
end{document}
Here's another example...you cannot typeset value
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%value{Q} will break
theQ
end{document}
The difference can also affect comparisons, since if compares tokens, not integers:
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
ifvalue{Q}2 Telse Ffi is false
iftheQ2 Telse Ffi is true
end{document}
The above example would show a match, were the ifs changed to ifnums, since ifnum will interpret/convert the character 2 into an integer. However, even that can get you into trouble for more complex cases.
Here, I can combine theQ with 3 to represent 23. The same does not apply for value{Q}3.
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%ifnumvalue{Q}3=23 Telse Ffi will break
ifnumtheQ3=23 Telse Ffi is true
end{document}
@user2925716ifnum <condition> <true code>else <false code>fiis TeX's way to perform integer comparisons, where the condition includes an=, a<or a>. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of23. If so it outputsT, if not anFis output. In the case ofvalue{Q}3, the test breaks, becausevalue{Q}3cannot be interpreted as a valid integer.
– Steven B. Segletes
8 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:if T jfiWhy?
– user2925716
7 hours ago
@user2925716 The commandif T jfiwill never print anything.ifcompares the next two fully expanded tokens. In this case, it compares if the tokenTis the same as the space token. If that were true, it prints out aT. No false instruction is given
– Steven B. Segletes
7 hours ago
|
show 5 more comments
thecounter typesets the result of the counter, be it in arabic, roman, etc, while value{counter} provides an integer value in return. In many, but not all, instances, the difference will go unnoticed.
The rule is, if you are looking for a character, use the...; if you are looking for an integer, use value{...}.
Here's an example where it matters. By typesetting the page number in roman (via pagenumbering{roman}), the option of romannumeralthepage is no longer an option, since it would be attempting romannumeral i, whereas romannumeralvalue{page} works fine.
documentclass{article}
pagenumbering{roman}
begin{document}
romannumeralvalue{page}
% romannumeralthepage will break
end{document}
Here's another example...you cannot typeset value
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%value{Q} will break
theQ
end{document}
The difference can also affect comparisons, since if compares tokens, not integers:
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
ifvalue{Q}2 Telse Ffi is false
iftheQ2 Telse Ffi is true
end{document}
The above example would show a match, were the ifs changed to ifnums, since ifnum will interpret/convert the character 2 into an integer. However, even that can get you into trouble for more complex cases.
Here, I can combine theQ with 3 to represent 23. The same does not apply for value{Q}3.
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%ifnumvalue{Q}3=23 Telse Ffi will break
ifnumtheQ3=23 Telse Ffi is true
end{document}
thecounter typesets the result of the counter, be it in arabic, roman, etc, while value{counter} provides an integer value in return. In many, but not all, instances, the difference will go unnoticed.
The rule is, if you are looking for a character, use the...; if you are looking for an integer, use value{...}.
Here's an example where it matters. By typesetting the page number in roman (via pagenumbering{roman}), the option of romannumeralthepage is no longer an option, since it would be attempting romannumeral i, whereas romannumeralvalue{page} works fine.
documentclass{article}
pagenumbering{roman}
begin{document}
romannumeralvalue{page}
% romannumeralthepage will break
end{document}
Here's another example...you cannot typeset value
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%value{Q} will break
theQ
end{document}
The difference can also affect comparisons, since if compares tokens, not integers:
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
ifvalue{Q}2 Telse Ffi is false
iftheQ2 Telse Ffi is true
end{document}
The above example would show a match, were the ifs changed to ifnums, since ifnum will interpret/convert the character 2 into an integer. However, even that can get you into trouble for more complex cases.
Here, I can combine theQ with 3 to represent 23. The same does not apply for value{Q}3.
documentclass{article}
begin{document}
newcounter{Q}
setcounter{Q}{2}
%ifnumvalue{Q}3=23 Telse Ffi will break
ifnumtheQ3=23 Telse Ffi is true
end{document}
edited 8 hours ago
answered 8 hours ago
Steven B. SegletesSteven B. Segletes
171k9 gold badges217 silver badges445 bronze badges
171k9 gold badges217 silver badges445 bronze badges
@user2925716ifnum <condition> <true code>else <false code>fiis TeX's way to perform integer comparisons, where the condition includes an=, a<or a>. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of23. If so it outputsT, if not anFis output. In the case ofvalue{Q}3, the test breaks, becausevalue{Q}3cannot be interpreted as a valid integer.
– Steven B. Segletes
8 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:if T jfiWhy?
– user2925716
7 hours ago
@user2925716 The commandif T jfiwill never print anything.ifcompares the next two fully expanded tokens. In this case, it compares if the tokenTis the same as the space token. If that were true, it prints out aT. No false instruction is given
– Steven B. Segletes
7 hours ago
|
show 5 more comments
@user2925716ifnum <condition> <true code>else <false code>fiis TeX's way to perform integer comparisons, where the condition includes an=, a<or a>. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of23. If so it outputsT, if not anFis output. In the case ofvalue{Q}3, the test breaks, becausevalue{Q}3cannot be interpreted as a valid integer.
– Steven B. Segletes
8 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:if T jfiWhy?
– user2925716
7 hours ago
@user2925716 The commandif T jfiwill never print anything.ifcompares the next two fully expanded tokens. In this case, it compares if the tokenTis the same as the space token. If that were true, it prints out aT. No false instruction is given
– Steven B. Segletes
7 hours ago
@user2925716
ifnum <condition> <true code>else <false code>fi is TeX's way to perform integer comparisons, where the condition includes an =, a < or a >. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of 23. If so it outputs T, if not an F is output. In the case of value{Q}3, the test breaks, because value{Q}3 cannot be interpreted as a valid integer.– Steven B. Segletes
8 hours ago
@user2925716
ifnum <condition> <true code>else <false code>fi is TeX's way to perform integer comparisons, where the condition includes an =, a < or a >. The particular case given is merely checking whether TeX finds the left side of the equation to equal a value of 23. If so it outputs T, if not an F is output. In the case of value{Q}3, the test breaks, because value{Q}3 cannot be interpreted as a valid integer.– Steven B. Segletes
8 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
Yes I've imagined that therefore I've deleted my comment. "by breaks" you mean it doesn't compile am I right?
– user2925716
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
@user2925716 yes...compile fails, rather than just yielding a "false" result.
– Steven B. Segletes
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:
if T jfi Why?– user2925716
7 hours ago
BTW I've tried this in XeTeX but it hasn't printed "j" as I expected:
if T jfi Why?– user2925716
7 hours ago
@user2925716 The command
if T jfi will never print anything. if compares the next two fully expanded tokens. In this case, it compares if the token T is the same as the space token. If that were true, it prints out a T. No false instruction is given– Steven B. Segletes
7 hours ago
@user2925716 The command
if T jfi will never print anything. if compares the next two fully expanded tokens. In this case, it compares if the token T is the same as the space token. If that were true, it prints out a T. No false instruction is given– Steven B. Segletes
7 hours ago
|
show 5 more comments
This is an interesting mathematical question. The number two hundred seventy-five can be represented in different ways:
- 275 in decimal notation with “Western digits”,
- ٢٧٥ in decimal notation with “Arabic digits”,
- CCLXXV in Roman numerals,
- 113 in hexadecimal digits,
- 100010011 in binary digits,
and many others (it's duecentosettantacinque in Italian).
When you define a new counter in LaTeX, with newcounter{foo}, also the command thefoo is defined, which will expand to a representation of the value stored in the counter; the command is initialized to provide the decimal representation of the counter, but one can say
renewcommand{thefoo}{roman{foo}}
and thereupon, calling thefoo when the counter stores the number 275 will produce
cclxxv
(after macro expansion). The initial definition is essentially equivalent to
newcommand{thefoo}{arabic{foo}}
A common case is the counter page: in the class book, the counter's representation uses roman in the front matter and arabic in the main matter and back matter.
However, the number stored in foo is indepedent of its representation: in some sense, the counter stores the abstract number, something not especially tied to a representation thereof. This abstract value is accessed to by value{foo}.
Let's say you have an application where a counter is bound to contain only the values from 0 to 3 and you want to represent these values with non numerical objects; you can define, for instance,
renewcommand{thefoo}{%
ifcasevalue{foo}%
apple% case 0
or
orange% case 1
or
apricot% case 2
or
strawberry% case 3
else
bummer% wrong setting found
fi
}
The conditional ifcase branches according to the number following it, in this case the abstract value stored in the counter.
You cannot say value{foo} in the document in order to print the value, because the abstract number can only be represented in some way and you have to specify which one. Instead, when TeX is looking for a number (such as after ifcase), then value{foo} is the right code to use.
The objection “but we could use arabic{foo} instead of value{foo}” is dismissed. You really want the abstract number there, not some representation thereof.
add a comment
|
This is an interesting mathematical question. The number two hundred seventy-five can be represented in different ways:
- 275 in decimal notation with “Western digits”,
- ٢٧٥ in decimal notation with “Arabic digits”,
- CCLXXV in Roman numerals,
- 113 in hexadecimal digits,
- 100010011 in binary digits,
and many others (it's duecentosettantacinque in Italian).
When you define a new counter in LaTeX, with newcounter{foo}, also the command thefoo is defined, which will expand to a representation of the value stored in the counter; the command is initialized to provide the decimal representation of the counter, but one can say
renewcommand{thefoo}{roman{foo}}
and thereupon, calling thefoo when the counter stores the number 275 will produce
cclxxv
(after macro expansion). The initial definition is essentially equivalent to
newcommand{thefoo}{arabic{foo}}
A common case is the counter page: in the class book, the counter's representation uses roman in the front matter and arabic in the main matter and back matter.
However, the number stored in foo is indepedent of its representation: in some sense, the counter stores the abstract number, something not especially tied to a representation thereof. This abstract value is accessed to by value{foo}.
Let's say you have an application where a counter is bound to contain only the values from 0 to 3 and you want to represent these values with non numerical objects; you can define, for instance,
renewcommand{thefoo}{%
ifcasevalue{foo}%
apple% case 0
or
orange% case 1
or
apricot% case 2
or
strawberry% case 3
else
bummer% wrong setting found
fi
}
The conditional ifcase branches according to the number following it, in this case the abstract value stored in the counter.
You cannot say value{foo} in the document in order to print the value, because the abstract number can only be represented in some way and you have to specify which one. Instead, when TeX is looking for a number (such as after ifcase), then value{foo} is the right code to use.
The objection “but we could use arabic{foo} instead of value{foo}” is dismissed. You really want the abstract number there, not some representation thereof.
add a comment
|
This is an interesting mathematical question. The number two hundred seventy-five can be represented in different ways:
- 275 in decimal notation with “Western digits”,
- ٢٧٥ in decimal notation with “Arabic digits”,
- CCLXXV in Roman numerals,
- 113 in hexadecimal digits,
- 100010011 in binary digits,
and many others (it's duecentosettantacinque in Italian).
When you define a new counter in LaTeX, with newcounter{foo}, also the command thefoo is defined, which will expand to a representation of the value stored in the counter; the command is initialized to provide the decimal representation of the counter, but one can say
renewcommand{thefoo}{roman{foo}}
and thereupon, calling thefoo when the counter stores the number 275 will produce
cclxxv
(after macro expansion). The initial definition is essentially equivalent to
newcommand{thefoo}{arabic{foo}}
A common case is the counter page: in the class book, the counter's representation uses roman in the front matter and arabic in the main matter and back matter.
However, the number stored in foo is indepedent of its representation: in some sense, the counter stores the abstract number, something not especially tied to a representation thereof. This abstract value is accessed to by value{foo}.
Let's say you have an application where a counter is bound to contain only the values from 0 to 3 and you want to represent these values with non numerical objects; you can define, for instance,
renewcommand{thefoo}{%
ifcasevalue{foo}%
apple% case 0
or
orange% case 1
or
apricot% case 2
or
strawberry% case 3
else
bummer% wrong setting found
fi
}
The conditional ifcase branches according to the number following it, in this case the abstract value stored in the counter.
You cannot say value{foo} in the document in order to print the value, because the abstract number can only be represented in some way and you have to specify which one. Instead, when TeX is looking for a number (such as after ifcase), then value{foo} is the right code to use.
The objection “but we could use arabic{foo} instead of value{foo}” is dismissed. You really want the abstract number there, not some representation thereof.
This is an interesting mathematical question. The number two hundred seventy-five can be represented in different ways:
- 275 in decimal notation with “Western digits”,
- ٢٧٥ in decimal notation with “Arabic digits”,
- CCLXXV in Roman numerals,
- 113 in hexadecimal digits,
- 100010011 in binary digits,
and many others (it's duecentosettantacinque in Italian).
When you define a new counter in LaTeX, with newcounter{foo}, also the command thefoo is defined, which will expand to a representation of the value stored in the counter; the command is initialized to provide the decimal representation of the counter, but one can say
renewcommand{thefoo}{roman{foo}}
and thereupon, calling thefoo when the counter stores the number 275 will produce
cclxxv
(after macro expansion). The initial definition is essentially equivalent to
newcommand{thefoo}{arabic{foo}}
A common case is the counter page: in the class book, the counter's representation uses roman in the front matter and arabic in the main matter and back matter.
However, the number stored in foo is indepedent of its representation: in some sense, the counter stores the abstract number, something not especially tied to a representation thereof. This abstract value is accessed to by value{foo}.
Let's say you have an application where a counter is bound to contain only the values from 0 to 3 and you want to represent these values with non numerical objects; you can define, for instance,
renewcommand{thefoo}{%
ifcasevalue{foo}%
apple% case 0
or
orange% case 1
or
apricot% case 2
or
strawberry% case 3
else
bummer% wrong setting found
fi
}
The conditional ifcase branches according to the number following it, in this case the abstract value stored in the counter.
You cannot say value{foo} in the document in order to print the value, because the abstract number can only be represented in some way and you have to specify which one. Instead, when TeX is looking for a number (such as after ifcase), then value{foo} is the right code to use.
The objection “but we could use arabic{foo} instead of value{foo}” is dismissed. You really want the abstract number there, not some representation thereof.
answered 7 hours ago
egregegreg
774k92 gold badges2018 silver badges3380 bronze badges
774k92 gold badges2018 silver badges3380 bronze badges
add a comment
|
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.
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%2f511435%2fthe-vs-value-what-is-the-difference%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
Related: The
thecommand– Werner
8 hours ago