*Bounty: 50*

*Bounty: 50*

# A mix of Roman, Greek, and single letter index entries

I am typing my thesis and have a mix of regular words, mathematics using greek symbols, and the occasional one letter word (such as the programming language C), and I noticed that my system for ensuring these are sorted correctly has fallen short.

# An example of the problem

Notice where the `$chi^2$`

appears in the index:

whereas what I am after is

# My current system

- If a regular roman word then just use index as intended such as
`index{Something}`

, including for single letter words such as`index{C}`

or`index{R}`

. - If there is a roman letter which I want to come first but in math mode then I use a single underscore, such as
`index{p_value@{$p$-value}}`

or`index{t_distribution@{$t$-distribution}}`

. The underscore ensures these appear first in their sort field. - If there is a leading greek mathematical letter then I want this to appear before the roman entries, so I use a double underscore such as
`index{d_delta_function@{$delta$-function}}`

.

Where possible I try and use a leading textual entry and so would use `Dirac-$delta$ function`

over `$delta$-function`

. However, I would use the greek symbols in preference to the greek letter spelt out, and so would use `$beta$-radiation`

rather than `beta-radiation`

.

# One workaround

I notice that if I write `Cindex{C@{C}}`

rather than `Cindex{C}`

then the sorting appears to be better, but I haven’t tested this fully and it smells like a bad practice. I have also in the past accidentally duplicated many index entries by having a trailing space such as `index{Something }`

which is a pain to debug, so am apprehensive about encouraging that I add one or two trailing spaces to every index.

*How can I get the desired sorting, and how should I revise my indexing system for future documents?*

# MWE

```
documentclass{article}
usepackage{makeidx}
makeindex
begin{document}
index{d_delta_function@{$ delta $-function}|see {Dirac-$ delta $ function}}
The Cindex{C}
%Cindex{C@{C}} % <-- This gives better sorting.
language is great, and C++index{C++} is okay, as too is $ C $#index{C_sharp@{C#}}, but if you want to compute a $ p $-valueindex{p_value@{$ p $-value}} for a Gaussian random variable with inverse cumulative distribution function $ Phi^{-1} $index{p__phi_inverse@{$ Phi^{-1} $}} then you may encounter difficulties with the probability densityindex{Probability density} if it tends to a Dirac-$ delta $index{Dirac_delta_function@{Dirac-$ delta $ function}} function.
clearpage
This becomes worse if you want to handle a $ chi^2 $-distributionindex{C@{$ chi^2 $-distribution}}
printindex
end{document}
```

# Related questions

Index ordering when using math symbols