glossaries use of sort key
after reading the manual of the glossaries packages I was under the impression that when you use the sort key that it would be sorted alphabetically according to the text given in this sort key. However, this MWE does not achieve this (in reality of course I have much more symbols so I really need the automatic sorting and it would take to long to define them in the correct order when I define them)
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b ,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
which gives this result:
where I would have expected this order if sorted alphabetically:
temperature coeffcient for a
temperature coeffcient for b
temperature coeffcient for de
temperature coeffcient for OP
what am I doing wrong?
glossaries sorting
|
show 3 more comments
after reading the manual of the glossaries packages I was under the impression that when you use the sort key that it would be sorted alphabetically according to the text given in this sort key. However, this MWE does not achieve this (in reality of course I have much more symbols so I really need the automatic sorting and it would take to long to define them in the correct order when I define them)
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b ,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
which gives this result:
where I would have expected this order if sorted alphabetically:
temperature coeffcient for a
temperature coeffcient for b
temperature coeffcient for de
temperature coeffcient for OP
what am I doing wrong?
glossaries sorting
i think that the string for the "sort" key needs to be in braces, like the other argument values.
– barbara beeton
Apr 13 '16 at 15:24
@barbara: you are probably right that it is better to put them in braces, but I have tested it and it does not change the order of the sorting unfortunately
– Ingrid
Apr 13 '16 at 15:40
did you make sure thatmakeindex
ran again before you ran the last iteration of latex? (that's the same order of steps that would be involved if you made a change to the sort of an index; theglossaries
package takes advantage of themakeindex
mechanism, which is a multi-step process.)
– barbara beeton
Apr 13 '16 at 15:44
Remove the spaces:sort={temperaturecoefficientfora}
– Ulrike Fischer
Apr 13 '16 at 15:44
@barbarabeeton Ingrid is using the noidx option, which means that the sorting is done by tex and not an external tool.
– Ulrike Fischer
Apr 13 '16 at 15:44
|
show 3 more comments
after reading the manual of the glossaries packages I was under the impression that when you use the sort key that it would be sorted alphabetically according to the text given in this sort key. However, this MWE does not achieve this (in reality of course I have much more symbols so I really need the automatic sorting and it would take to long to define them in the correct order when I define them)
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b ,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
which gives this result:
where I would have expected this order if sorted alphabetically:
temperature coeffcient for a
temperature coeffcient for b
temperature coeffcient for de
temperature coeffcient for OP
what am I doing wrong?
glossaries sorting
after reading the manual of the glossaries packages I was under the impression that when you use the sort key that it would be sorted alphabetically according to the text given in this sort key. However, this MWE does not achieve this (in reality of course I have much more symbols so I really need the automatic sorting and it would take to long to define them in the correct order when I define them)
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b ,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
which gives this result:
where I would have expected this order if sorted alphabetically:
temperature coeffcient for a
temperature coeffcient for b
temperature coeffcient for de
temperature coeffcient for OP
what am I doing wrong?
glossaries sorting
glossaries sorting
asked Apr 13 '16 at 15:08
IngridIngrid
69110
69110
i think that the string for the "sort" key needs to be in braces, like the other argument values.
– barbara beeton
Apr 13 '16 at 15:24
@barbara: you are probably right that it is better to put them in braces, but I have tested it and it does not change the order of the sorting unfortunately
– Ingrid
Apr 13 '16 at 15:40
did you make sure thatmakeindex
ran again before you ran the last iteration of latex? (that's the same order of steps that would be involved if you made a change to the sort of an index; theglossaries
package takes advantage of themakeindex
mechanism, which is a multi-step process.)
– barbara beeton
Apr 13 '16 at 15:44
Remove the spaces:sort={temperaturecoefficientfora}
– Ulrike Fischer
Apr 13 '16 at 15:44
@barbarabeeton Ingrid is using the noidx option, which means that the sorting is done by tex and not an external tool.
– Ulrike Fischer
Apr 13 '16 at 15:44
|
show 3 more comments
i think that the string for the "sort" key needs to be in braces, like the other argument values.
– barbara beeton
Apr 13 '16 at 15:24
@barbara: you are probably right that it is better to put them in braces, but I have tested it and it does not change the order of the sorting unfortunately
– Ingrid
Apr 13 '16 at 15:40
did you make sure thatmakeindex
ran again before you ran the last iteration of latex? (that's the same order of steps that would be involved if you made a change to the sort of an index; theglossaries
package takes advantage of themakeindex
mechanism, which is a multi-step process.)
– barbara beeton
Apr 13 '16 at 15:44
Remove the spaces:sort={temperaturecoefficientfora}
– Ulrike Fischer
Apr 13 '16 at 15:44
@barbarabeeton Ingrid is using the noidx option, which means that the sorting is done by tex and not an external tool.
– Ulrike Fischer
Apr 13 '16 at 15:44
i think that the string for the "sort" key needs to be in braces, like the other argument values.
– barbara beeton
Apr 13 '16 at 15:24
i think that the string for the "sort" key needs to be in braces, like the other argument values.
– barbara beeton
Apr 13 '16 at 15:24
@barbara: you are probably right that it is better to put them in braces, but I have tested it and it does not change the order of the sorting unfortunately
– Ingrid
Apr 13 '16 at 15:40
@barbara: you are probably right that it is better to put them in braces, but I have tested it and it does not change the order of the sorting unfortunately
– Ingrid
Apr 13 '16 at 15:40
did you make sure that
makeindex
ran again before you ran the last iteration of latex? (that's the same order of steps that would be involved if you made a change to the sort of an index; the glossaries
package takes advantage of the makeindex
mechanism, which is a multi-step process.)– barbara beeton
Apr 13 '16 at 15:44
did you make sure that
makeindex
ran again before you ran the last iteration of latex? (that's the same order of steps that would be involved if you made a change to the sort of an index; the glossaries
package takes advantage of the makeindex
mechanism, which is a multi-step process.)– barbara beeton
Apr 13 '16 at 15:44
Remove the spaces:
sort={temperaturecoefficientfora}
– Ulrike Fischer
Apr 13 '16 at 15:44
Remove the spaces:
sort={temperaturecoefficientfora}
– Ulrike Fischer
Apr 13 '16 at 15:44
@barbarabeeton Ingrid is using the noidx option, which means that the sorting is done by tex and not an external tool.
– Ulrike Fischer
Apr 13 '16 at 15:44
@barbarabeeton Ingrid is using the noidx option, which means that the sorting is done by tex and not an external tool.
– Ulrike Fischer
Apr 13 '16 at 15:44
|
show 3 more comments
2 Answers
2
active
oldest
votes
I'm not sure why the standard
sort order isn't working, but it works fine if you switch to letter
:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
This produces:
Incidentally, if you want to sort by a different field (the description
in this case), you can redefine the hook that sets the value of the sort
key. For example:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
makeatletter
renewcommand{glsprestandardsort}[3]{%
protected@edef#1{glsentrydesc{#3}}%
}
makeatother
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b}
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a}
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de}
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP}
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
Edit:
A better redefinition of glsprestandardsort
is:
glssanitizesorttrue
renewcommand{glsprestandardsort}[3]{%
glsfieldfetch{#3}{desc}{#1}%
glsdosanitizesort
}
(This no longer needs the makeatletter
...makeatother
part.)
The glssanitizesorttrue
bit will make glsdosanitizesort
apply @onelevel@sanitize
to the sort field, which will allow commands like si
to appear in the description (but it will apply the same logic as makeindex
and treat si
as the sequence of characters ,
s
and i
).
The second argument of glsprestandardsort
is the glossary type, so you can test it to vary the way the sort
field is set according to the glossary. For example:
renewcommand{glsprestandardsort}[3]{%
ifthenelse{equal{#2}{main}}%
{%
glsfieldfetch{#3}{desc}{#1}%
}{}%
glsdosanitizesort
}
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
@Ingrid updated my answer to allow forsi
.
– Nicola Talbot
Apr 14 '16 at 9:20
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
add a comment |
Remove the spaces in the sort key values:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperaturecoefficientforb,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperaturecoefficientfora,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperaturecoefficientforde,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperaturecoefficientforop,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
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/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%2f304092%2fglossaries-use-of-sort-key%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
I'm not sure why the standard
sort order isn't working, but it works fine if you switch to letter
:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
This produces:
Incidentally, if you want to sort by a different field (the description
in this case), you can redefine the hook that sets the value of the sort
key. For example:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
makeatletter
renewcommand{glsprestandardsort}[3]{%
protected@edef#1{glsentrydesc{#3}}%
}
makeatother
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b}
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a}
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de}
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP}
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
Edit:
A better redefinition of glsprestandardsort
is:
glssanitizesorttrue
renewcommand{glsprestandardsort}[3]{%
glsfieldfetch{#3}{desc}{#1}%
glsdosanitizesort
}
(This no longer needs the makeatletter
...makeatother
part.)
The glssanitizesorttrue
bit will make glsdosanitizesort
apply @onelevel@sanitize
to the sort field, which will allow commands like si
to appear in the description (but it will apply the same logic as makeindex
and treat si
as the sequence of characters ,
s
and i
).
The second argument of glsprestandardsort
is the glossary type, so you can test it to vary the way the sort
field is set according to the glossary. For example:
renewcommand{glsprestandardsort}[3]{%
ifthenelse{equal{#2}{main}}%
{%
glsfieldfetch{#3}{desc}{#1}%
}{}%
glsdosanitizesort
}
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
@Ingrid updated my answer to allow forsi
.
– Nicola Talbot
Apr 14 '16 at 9:20
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
add a comment |
I'm not sure why the standard
sort order isn't working, but it works fine if you switch to letter
:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
This produces:
Incidentally, if you want to sort by a different field (the description
in this case), you can redefine the hook that sets the value of the sort
key. For example:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
makeatletter
renewcommand{glsprestandardsort}[3]{%
protected@edef#1{glsentrydesc{#3}}%
}
makeatother
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b}
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a}
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de}
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP}
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
Edit:
A better redefinition of glsprestandardsort
is:
glssanitizesorttrue
renewcommand{glsprestandardsort}[3]{%
glsfieldfetch{#3}{desc}{#1}%
glsdosanitizesort
}
(This no longer needs the makeatletter
...makeatother
part.)
The glssanitizesorttrue
bit will make glsdosanitizesort
apply @onelevel@sanitize
to the sort field, which will allow commands like si
to appear in the description (but it will apply the same logic as makeindex
and treat si
as the sequence of characters ,
s
and i
).
The second argument of glsprestandardsort
is the glossary type, so you can test it to vary the way the sort
field is set according to the glossary. For example:
renewcommand{glsprestandardsort}[3]{%
ifthenelse{equal{#2}{main}}%
{%
glsfieldfetch{#3}{desc}{#1}%
}{}%
glsdosanitizesort
}
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
@Ingrid updated my answer to allow forsi
.
– Nicola Talbot
Apr 14 '16 at 9:20
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
add a comment |
I'm not sure why the standard
sort order isn't working, but it works fine if you switch to letter
:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
This produces:
Incidentally, if you want to sort by a different field (the description
in this case), you can redefine the hook that sets the value of the sort
key. For example:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
makeatletter
renewcommand{glsprestandardsort}[3]{%
protected@edef#1{glsentrydesc{#3}}%
}
makeatother
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b}
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a}
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de}
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP}
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
Edit:
A better redefinition of glsprestandardsort
is:
glssanitizesorttrue
renewcommand{glsprestandardsort}[3]{%
glsfieldfetch{#3}{desc}{#1}%
glsdosanitizesort
}
(This no longer needs the makeatletter
...makeatother
part.)
The glssanitizesorttrue
bit will make glsdosanitizesort
apply @onelevel@sanitize
to the sort field, which will allow commands like si
to appear in the description (but it will apply the same logic as makeindex
and treat si
as the sequence of characters ,
s
and i
).
The second argument of glsprestandardsort
is the glossary type, so you can test it to vary the way the sort
field is set according to the glossary. For example:
renewcommand{glsprestandardsort}[3]{%
ifthenelse{equal{#2}{main}}%
{%
glsfieldfetch{#3}{desc}{#1}%
}{}%
glsdosanitizesort
}
I'm not sure why the standard
sort order isn't working, but it works fine if you switch to letter
:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperature coefficient for b,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperature coefficient for a,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperature coefficient for de,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperature coefficient for op,
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
This produces:
Incidentally, if you want to sort by a different field (the description
in this case), you can redefine the hook that sets the value of the sort
key. For example:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
makeatletter
renewcommand{glsprestandardsort}[3]{%
protected@edef#1{glsentrydesc{#3}}%
}
makeatother
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b}
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a}
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de}
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP}
}
begin{document}
printnoidxglossary[sort=letter,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
Edit:
A better redefinition of glsprestandardsort
is:
glssanitizesorttrue
renewcommand{glsprestandardsort}[3]{%
glsfieldfetch{#3}{desc}{#1}%
glsdosanitizesort
}
(This no longer needs the makeatletter
...makeatother
part.)
The glssanitizesorttrue
bit will make glsdosanitizesort
apply @onelevel@sanitize
to the sort field, which will allow commands like si
to appear in the description (but it will apply the same logic as makeindex
and treat si
as the sequence of characters ,
s
and i
).
The second argument of glsprestandardsort
is the glossary type, so you can test it to vary the way the sort
field is set according to the glossary. For example:
renewcommand{glsprestandardsort}[3]{%
ifthenelse{equal{#2}{main}}%
{%
glsfieldfetch{#3}{desc}{#1}%
}{}%
glsdosanitizesort
}
edited Apr 14 '16 at 17:36
answered Apr 13 '16 at 16:08
Nicola TalbotNicola Talbot
34.3k259105
34.3k259105
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
@Ingrid updated my answer to allow forsi
.
– Nicola Talbot
Apr 14 '16 at 9:20
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
add a comment |
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
@Ingrid updated my answer to allow forsi
.
– Nicola Talbot
Apr 14 '16 at 9:20
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
thanks, this last solution is indeed much more elegant and achieves what I want to do much easier. It works in the MWE, but in my large document, it gives errors as sometimes I am using si{} in the description which apparently is no longer allowed
– Ingrid
Apr 14 '16 at 8:48
@Ingrid updated my answer to allow for
si
.– Nicola Talbot
Apr 14 '16 at 9:20
@Ingrid updated my answer to allow for
si
.– Nicola Talbot
Apr 14 '16 at 9:20
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
thanks works like a charm. I am encountering another problem though. I am also having a list of acronyms and now they are also sorted based on the description whereas I would like this list to be sorted alphabetically based on their acronym. Is it possible with this method to have two different methods for each list?
– Ingrid
Apr 14 '16 at 14:06
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
@Ingrid Yes, I've updated my answer to test for the glossary type.
– Nicola Talbot
Apr 14 '16 at 17:37
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
thanks for your very quick reply's. They are really appreciated since I am running against a deadline! I clearly still have a lot to learn as I can currently only apply the standard stuff but am clueless about the stuff behind the scenes which is of course necessary when you want to do the cool stuff
– Ingrid
Apr 15 '16 at 8:07
add a comment |
Remove the spaces in the sort key values:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperaturecoefficientforb,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperaturecoefficientfora,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperaturecoefficientforde,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperaturecoefficientforop,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
add a comment |
Remove the spaces in the sort key values:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperaturecoefficientforb,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperaturecoefficientfora,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperaturecoefficientforde,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperaturecoefficientforop,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
add a comment |
Remove the spaces in the sort key values:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperaturecoefficientforb,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperaturecoefficientfora,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperaturecoefficientforde,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperaturecoefficientforop,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
Remove the spaces in the sort key values:
documentclass{report}
usepackage{lipsum}
usepackage{hyperref}
usepackage[acronym,nogroupskip,nonumberlist,nopostdot,toc]{glossaries}
makenoidxglossaries
newglossaryentry{thetab}
{%
name={$Theta_{b}$},
description={temperature coefficient for b},
sort=temperaturecoefficientforb,
}
newglossaryentry{thetaa}
{%
name={$Theta_{a}$},
description={temperature coefficient for a},
sort=temperaturecoefficientfora,
}
newglossaryentry{thetade}
{%
name={$Theta_{de}$},
description={temperature coefficient for de},
sort=temperaturecoefficientforde,
}
newglossaryentry{thetaOP}
{%
name={$Theta_{OP}$},
description={temperature coefficient for OP},
sort=temperaturecoefficientforop,
}
begin{document}
printnoidxglossary[sort=standard,title={List of Symbols}]
chapter{first chapter}
lipsum
testing gls{thetab} and gls{thetaa}
some more references gls{thetade} and gls{thetaOP}
end{document}
answered Apr 13 '16 at 15:48
Ulrike FischerUlrike Fischer
192k8302683
192k8302683
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%2f304092%2fglossaries-use-of-sort-key%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
i think that the string for the "sort" key needs to be in braces, like the other argument values.
– barbara beeton
Apr 13 '16 at 15:24
@barbara: you are probably right that it is better to put them in braces, but I have tested it and it does not change the order of the sorting unfortunately
– Ingrid
Apr 13 '16 at 15:40
did you make sure that
makeindex
ran again before you ran the last iteration of latex? (that's the same order of steps that would be involved if you made a change to the sort of an index; theglossaries
package takes advantage of themakeindex
mechanism, which is a multi-step process.)– barbara beeton
Apr 13 '16 at 15:44
Remove the spaces:
sort={temperaturecoefficientfora}
– Ulrike Fischer
Apr 13 '16 at 15:44
@barbarabeeton Ingrid is using the noidx option, which means that the sorting is done by tex and not an external tool.
– Ulrike Fischer
Apr 13 '16 at 15:44