TeX - LaTeX Asked by Michael Engeli on April 16, 2021
I have the following code and can’t find out the command to sort my abbreviation list alphabetically.
documentclass [11pt, a4paper] {article}
usepackage{acro} %list of abbreviations
acsetup{first-style=short} %list of abbreviations
input{abbreviations.tex} %define abbreviations in this file.
begin{document}
addcontentsline{toc}{section}{numberline{}List of Abbreviations}
acuseall %to make all abbreviations appear in list of abbreviations (formally uses all of them)
printacronyms[heading=none,include-classes={abbrev},sort=true] % print list of abbreviations
end{document}
Currently, the compiled document looks like this:
EDIT
Here are some lines from the abbreviations.tex
:
%------------------------------------
% DEFINING ABBREVIATIONS
%------------------------------------
DeclareAcronym{1}{ % every abbreviation must be defined this way
short = {LDL} , % abbreviation shown in the list of abbrev
long = {Low-density lipoprotein} , % long text shown in the list of abbrev
class = {abbrev}
}
DeclareAcronym{2}{
short = {HDL} ,
long = {High-density lipoprotein},
class = {abbrev}
}
DeclareAcronym{3}{
short = {RYGB} ,
long = {Roux-en-Y gastric bypass},
class = {abbrev}
}
The first argument to DeclareAcronym
is used for sorting.
documentclass [11pt, a4paper] {article}
usepackage{acro} %list of abbreviations
acsetup{first-style=short}
%input{abbreviations.tex} %define abbreviations in this file.
DeclareAcronym{LDL}{ % every abbreviation must be defined this way
short = {LDL}, % abbreviation shown in the list of abbrev
long = {Low-density lipoprotein}, % long text shown in the list of abbrev
class = {abbrev}
}
DeclareAcronym{HDL}{
short = {HDL},
long = {High-density lipoprotein},
class = {abbrev}
}
DeclareAcronym{RYGB}{
short = {RYGB},
long = {Roux-en-Y gastric bypass},
class = {abbrev}
}
begin{document}
acuseall
cleardoublepage
addcontentsline{toc}{section}{protectnumberline{}List of Abbreviations}
printacronyms[heading=none,include-classes={abbrev},sort=true]
end{document}
Note the final changes.
With new versions of the acro
package, something has changed. In particular, the ID is no longer used for sorting, but short
is. However, one can add a sort
key to solve sorting issues. If not specified, the entry is sorted by the short
key. Also classes
now is tag
and include-classes
is include
. In the example code below, the sort
keys are commented because not really needed.
documentclass [11pt, a4paper] {article}
usepackage{acro} %list of abbreviations
acsetup{first-style=short}
%input{abbreviations.tex} %define abbreviations in this file.
DeclareAcronym{LDL}{ % every abbreviation must be defined this way
short = {LDL}, % abbreviation shown in the list of abbrev
long = {Low-density lipoprotein}, % long text shown in the list of abbrev
tag = {abbrev},
%sort = {LDL},
}
DeclareAcronym{HDL}{
short = {HDL},
long = {High-density lipoprotein},
tag = {abbrev},
%sort = {HDL},
}
DeclareAcronym{RYGB}{
short = {RYGB},
long = {Roux-en-Y gastric bypass},
tag = {abbrev},
%sort = {RYGB},
}
begin{document}
acuseall
cleardoublepage
addcontentsline{toc}{section}{protectnumberline{}List of Abbreviations}
printacronyms[heading=none,include=abbrev,sort]
end{document}
Correct answer by egreg on April 16, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP