0

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 :) ):

\documentclass[a4paper,oneside,11pt,parskip=half]{scrreprt}

\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}

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

\newglossary[ilg]{indizes}{iyi}{iyg}{Indizes}

\setlength{\glsdescwidth}{12cm}
\makeglossaries
\glsnoexpandfields

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

%% abbreviations
\newcommand{\TES}{ES}   
\newcommand{\HT}{HT}        
\newcommand{\NT}{NT}
%% sub- and superscripts
\newcommand{\TESi}{\mathit{\TES}}
\newcommand{\HTi}{\mathit{\HT}}
\newcommand{\NTi}{\mathit{\NT}}
\newcommand{\IT}{I}
% 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}

\begin{document}

\glsaddall
\printglossary[type=indizes, style=fixedglslong]

\end{document}

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

1

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

\usepackage[
    acronym, toc, nonumberlist, nopostdot, nomain, nogroupskip, 
    sanitizesort=false  % false expands commands
]{glossaries}

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 .