TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From http://www.latex-community.org/forum/viewtopic.php?f=51&t=12595

I want to compile an new English terms on my proffesional field collections. It's much like a dictionary but in reverse sort of words for learning convenience, e.g.

romance ...
...(other words whose root is "-ance")
science ...
romantic ...
Titantic ...
scientific ...

I am going to write the words as follow

description={(corresponding paraphrase)}

but can't find any sort option fit my demand. Please give me a hand.

share|improve this question
Please repost your question here again in full. Posts on TeX.SX must be mostly self-contained. Thanks. – Martin Scharrer Apr 6 '11 at 10:45
…and with a more descriptive title. – Will Robertson Apr 6 '11 at 12:17
I've pasted in the text there, but it's still not clear to me what the question is after. This example doesn't make clear how this kind of index differs from a dictionary. – Charles Stewart Apr 6 '11 at 13:13
It sounds as if the words should be sorted depending on their endings (-ance, -tic). I think this could be only done if one add a sensible sort key to each entry. – Ulrike Fischer Apr 6 '11 at 13:36
I understand your question. It seems you can use a quick fix with some scripting, for the .glo file. To convert \glossaryentry{abc?blah blah} to \glossaryentry{cba?blah blah}. It won't be very difficult to implement with awk, perl, etc. – Leo Liu Apr 6 '11 at 15:51

If I understand you right you want to compile a dictionary based on some kind of two-level sorting procedure: Firstly, group the words according to a set of predefined suffixes (such as "antic" in romantic or semantic) and sort the groups; secondly, sort the words of each group.

You can do this using the tools of the xstring package:



Define an appropriate wrapper around the \newglossaryentry command provided by the glossaries package:

  \StrExpand{{\root\suffix}{name=\root\suffix, description={#2}, sort=\suffix\root}}{\keyvallist}%

Now, define dictionary entries as follows:

\mynewglossaryentry{sem-antic}{description of semantic}
\mynewglossaryentry{rom-antic}{description of romantic}
\mynewglossaryentry{immin-ence}{description of imminence}
\mynewglossaryentry{depend-ence}{description of dependence}
\mynewglossaryentry{immin-ent}{description of imminent}
\mynewglossaryentry{depend-ent}{description of dependent}


The hyphen in the first argument of \mynewglossaryentry is solely used to indicate the suffixes controlling first-level sorting. It will not show up in the dictionary. Moreover, it is not part of the label of a dictionary entry—the label is the word itself:


\gls{semantic}, \gls{romantic}, \gls{imminence}, \gls{dependence}, \gls{imminent}, \gls{dependent}



The resulting output is:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.