Skip to content

glossaries grouping by first letter

João M. Lourenço edited this page Mar 15, 2021 · 1 revision

Lots of Acronyms? How to group them by first letter?

Thanks to André Rodrigues for these instructions https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/novathesis/TQnZpeqgHrQ/JUxkPouMBwAJ


Works with:

  • Version 4.x?? (please confirm!)
  • Version 5.x?? (please confirm!)

Past the following code in the template (I pasted it in the section "Customisation of some packages":

\makenoidxglossaries
\makeatletter
\begingroup%
  \catcode0=12 %
  \gdef\chrdef#1#2{%
    \begingroup%
      \lccode0=\numexpr(#2)\relax%
    \lowercase{\endgroup%
      \def#1{^^@}%
    }%
  }%
\endgroup
\def\@gls@getgrouptitle#1#2{%
  \DTLifint {#1}{%
    \chrdef\@tmp@char{#1}%
  }{%
    \def\@tmp@char{#1}%
  }%
  \ifcsundef {\@tmp@char groupname}{%
    \def #2{\@tmp@char}%
  }{%
    \letcs #2{\@tmp@char groupname}%
  }%
}
\makeatother
\newcommand{\Agroupname}{Name group A}
\newcommand{\Bgroupname}{Name group B}
\newcommand{\Dgroupname}{Name group C}
\newcommand{\Dgroupname}{Name group D}
\newcommand{\Egroupname}{Name group E}
etc...

The need for this code appears to be due to the use of \printnoidxglossaries in the template. Source: http://tex.stackexchange.com/questions/296197/change-group-names-when-using-noidxglossaries

In the 'acronyms.tex' file, the entries must follow this type

\newacronym[sort=Aabc]{ABC}{ABC}{Definition}

Or this one for mathematical symbols:

\newacronym[sort=Aalpha]{alpha}{{$\alpha$}}{Definition}

The first character after 'sort=' defines which group the symbol belongs too: 'A' means the symbols belong to 'Name group A' defined above.

The glossary style must be one that includes groups:

\setglossarystyle{alttreegroup}

or

\setglossarystyle{indexgroup} 

or

\setglossarystyle{listgroup}

(this command can be added to the acronyms file or to the template file)