# Sort the list of symbols

I have a list of symbols in my thesis with the glossaries-extra package. I want to sort the list of symbols in some fashions, e.g., sorting w.r.t. the first alphabet of the respective descriptions, or sorting w.r.t. the order placed in the definition. As for now, they seem to be unsorted and I hope there exists an option such as sort= for this purpose.

MWE:

\documentclass[12pt]{article}
\usepackage[symbols]{glossaries-extra}
\makeglossaries

\glsxtrnewsymbol
[description = {Penalization power used in the SIMP approach}]
{penalization-power}
{$p$}

\glsxtrnewsymbol
[description = {Filter radius used in the SIMP approach}]
{$r$}

\glsxtrnewsymbol
{force}
{$F$}

\glsxtrnewsymbol
[description = {Young's modulus}]
{elastic-modulus}
{$E$}

\glsxtrnewsymbol
[description = {Young's modulus in element $e$}]
{element-elastic-modulus}
{$E_{e}$}

\glsxtrnewsymbol
[description = {Artificial Young's modulus assigned to void regions (ersatz material)}]
{artificial-elastic-modulus}
{$E_{min}$}

\glsxtrnewsymbol
[description = {mass density}]
{mass-density}
{$\rho$}

\begin{document}

\printglossary[type=symbols,title={List of Symbols}]

\printglossary
\end{document}

• gloassaries should be sorted (according to the user manual). Using glossaries-extra, the sort is based on the "label" you used in \glsextrnewsymbol (the second argument). So in your example, it would be sorted with E_min first, then E, E_e, r, F, followed by \rho and p. Apr 26 at 13:45

glossaries-extra is a an extension to the glossaries package

See glossaries-extra package document P.19, https://mirror.csclub.uwaterloo.ca/CTAN/macros/latex/contrib/glossaries-extra/glossaries-extra-manual.pdf

\glsxtrnewsymbol[〈options〉]{〈label〉}{〈symbol〉}

which is equivalent to the command in glossaries package

\newglossaryentry{〈label〉}{name={〈symbol〉},
sort={〈label〉},type=symbols,category=symbol,〈options〉}


Note that the sort key is set to the 〈label〉 not the 〈symbol〉 as the symbol will likely contain commands.

The label filed is the variable when you want use the the symbol in document with \gls{label}. So you wanna define it with some easy remember term such as:

\glsxtrnewsymbol
[sort={1},description = {mass density}]
{md}
{\ensuremath{\rho}}


The symbol field define how the symbol will be displayed in document when you call \gls{label} (e.g. \gls{md} will type \ensuremath{\rho} in the document).

notice: initially the md term will denote as a sort key, so the sorting will depend on the order of first letter m. But you can manually change it by adding sort={1} in the option. In this way, this entry will appear at first in the list. Because the sorting order is numbers follow by letters. Also, make sure putting \ensuremath{} for the symbol in order to make it usable in the math mode ($...$ not work). And put automake in the package option, so each time you change your symbol definition latex will update the symbol list for you. This is example how it will work:

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage[automake,symbols]{glossaries-extra}

\glsxtrnewsymbol
[sort={f},description = {Penalization power used in the SIMP approach}]
{p}
{\ensuremath{p}}

\glsxtrnewsymbol
[sort={e},description = {Filter radius used in the SIMP approach}]
{Rf}
{\ensuremath{r}}

\glsxtrnewsymbol
{f}
{\ensuremath{F}}

\glsxtrnewsymbol
[sort={c},description = {Young's modulus}]
{E}
{\ensuremath{E}}

\glsxtrnewsymbol
[sort={b},description = {Young's modulus in element $e$}]
{Ee}
{\ensuremath{E_e}}

\glsxtrnewsymbol
[sort={a},description = {Artificial Young's modulus assigned to void regions (ersatz material)}]
{Ea}
{\ensuremath{E_{min}}}

\glsxtrnewsymbol
[sort={1},description = {mass density}]
{md}
{\ensuremath{\rho}}
\makeglossaries

\begin{document}
$\gls{md}=\gls{Ee}\times\gls{f}\times\gls{Ea}$ % equation doesn't make any sense, it is just a example