For my documents, I like to define sub- and super-scripts (in German: Indizes) as commands with \newcommand{}{} to make a cascading structure of shortcuts for frequently used abbreviations. This has the huge advantage, that I can easily change all related abbreviations and subscripts with one single line. For example:

  • Abbreviation TES for thermal energy storage \newcommand{\TES}{TES}
  • Also defined as as subscript or math variable with \newcommand{\TESi}{\mathit{\TES}} for beautiful math text formatting
  • Used in text with \TES{}
  • Used in math. symbols with $V_{\TESi}$ for the volume of a TES
  • Added to glossaries of sub- and superscripts with \newacronym[type=indizes]{tes}{$\TESi$}{thermal energy storage}

The last step is causing some trouble: When sorting entries, glossaries seems to be sorting by the name of the command instead of the string produced by the command.
Meaning that if I rename the initial abbreviation from newcommand{\TES}{TES} to newcommand{\TES}{ES}, the glossaries are sorted by \TES instead of ES. This gets even worse, when abbreviations not defined by newcommand are added (in quite some very clear cases there is simply no other useful abbreviation), the sorting is completely off.
Adding \newacronym[type=indizes,sort=ES] works, but again I'd prefer an implicit solution for flexibility, like \newacronym[type=indizes,sort=\TES], which again sorts by TES and not ES...

My minimum working example is (yeah, I could drop the glossary style definition, but it is much easier to read like this :) ):




\usepackage[acronym, toc, nonumberlist, nopostdot, nomain, nogroupskip]{glossaries}



% Stil für Indizes und Abkürzungen
    \setglossarystyle{long}% base this style on the list style
    \renewenvironment{theglossary}{% Change the table type --> 3 columns
    \renewcommand*{\glossentry}[2]{%        Change the displayed items
        \glstarget{##1}{\glossentryname{##1}} %
        & \glossentrydesc{##1} \tabularnewline

%% abbreviations
%% sub- and superscripts
% glossary for sub- and superscripts:
\newacronym[type=indizes]{TES}{$\TESi$}{thermal energy storage}
\newacronym[type=indizes]{HT}{$\HTi$}{high temperature}
\newacronym[type=indizes]{NT}{$\NTi$}{low temperature}
\newacronym[type=indizes]{itens}{$I$}{inertia tensor}


\printglossary[type=indizes, style=fixedglslong]


Is there any way to sort the items correctly, that means by the strings which are actually printed in the document? Or can I somehow provide an additional sort key to newacronym, as it is possible for \newglossaryentry? I checked the glossaries doc and tried all kinds of variations, but it didn't seem to be working.
Could switching to xindy make it work? What could be unexpected side effects?

I'd expect the sorting of the glossary to look like this:

  1. ES thermal energy storage
  2. HT high temperature
  3. I inertia tensor
  4. NT low temperature

1 Answer 1


Ok, I found the answer. If I set sanitizesort=false as a glossaries package option, sort keys will be expanded:

    acronym, toc, nonumberlist, nopostdot, nomain, nogroupskip, 
    sanitizesort=false  % false expands commands

There still seem to be some sorting issues with some explicitly defined non-command entries, but in genereal it is working fine.

edit: Now that I know what "sanitizing" means in Latex and thus searched for it, found this question/answer dealing with the same problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .