MakeIndex, Nomenclature, Glossaries and AcronymsCase sensitive sorts with makeindex

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Case sensitive sorts with makeindex

Post by kaiserkarl13 »

Is it possible to get makeindex to sort A>B>a instead of A>a>B? I'm using nomencl.sty both with and without prefixes; I've also tried setting the prefix to '+' or '=' instead of 'a' to no avail.

I can get symbols to sort ahead of all other characters, but I can't get capital letters grouped ahead of small ones.

What it looks like now:

\Gamma
\Pi
\pi
A
a
B
b
...


What I'd like:
\Gamma
\Pi
\pi
A
B
...
a
b
...

Any suggestions?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Case sensitive sorts with makeindex

Post by localghost »

Could be difficult in the best case. You may try Xindy as an alternative. For Windows it is only included in the TeX Live distribution at the moment. I don't know if the upcoming version 2.8 of MiKTeX will come with it.


Best regards
Thorsten
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Case sensitive sorts with makeindex

Post by kaiserkarl13 »

I figured out how to get it to work with minimal effort:

Declare symbols via

Code: Select all

\nomenclature[*C]{$\Gamma$}{blah}
Declare upper case letters via

Code: Select all

\nomenclature[+C]{$C$}{blah}
Declare lower case letters via

Code: Select all

\nomenclature[-c]{$c$}{blah}
This way, the first letter of each is *, +, or - (which are sorted in that order due to their ASCII codes).

For those that use VIM, the following commands are handy for updating the upper and lower case letters:

Code: Select all

  %s/\(nomenclature\[\)\([A-Z]\)/\1+\2/
  %s/\(nomenclature\[\)\([a-z]\)/\1-\2/
You'll have to do the symbols manually, since those don't typically have a sorting argument (e.g., [c]). I used optional arguments like [*H], [*Y], etc. to ensure that \Psi ([*Y]) gets sorted after \Theta ([*H]).

Working example:

Code: Select all

\nomenclature[-aa]{$a_a$}{asntoehu}%
\nomenclature[*C]{$\Gamma$}{asnteohu}%
\nomenclature[*H]{$\Omega$}{asnteohu}%
\nomenclature[+Aa]{$A_a$}{asontehu}%
\nomenclature[+AA]{$A_A$}{santoehu}%
\nomenclature[+Ba]{$B_a$}{asntoehu}%
\nomenclature[*Y]{$\Psi$}{asnteohu}%
which produces the order
\Gamma
\Omega
\Psi
A_A
A_a
B_a
a_a

This seems to solve the problem adequately.
Post Reply