# Give a symbol an alphabetical “order”?

I've defined a C++ symbol in latex as \CC, which works fine:

\newcommand{\CC}{C\nolinebreak\hspace{-.05em}\raisebox{.4ex}{\tiny\bf +}\nolinebreak\hspace{-.10em}\raisebox{.4ex}{\tiny\bf +}}


However, I'd also like to include it in my index. I'm currently just using \index{\CC}, but this puts the entry for C++ at the start of the index (presumably because it's a symbol):

I'd like to instead preserve the alphabetical order of the C in the index. How can I achieve this?

• Try \index{C++@\CC} – Nicola Talbot Aug 20 '14 at 12:43
• @NicolaTalbot Thanks, that did the trick! If you post as an answer I'll accept it. – berry120 Aug 20 '14 at 12:48

You can override the default sort key using the @ specifier:

\index{C++@\CC}


This tells makeindex to sort according to C++ but to use \CC in the index.

You could simplify this repetitive indexing by redefining your C++-command:

\newcommand{\CC}{%
C\nolinebreak\hspace{-.05em}\raisebox{.4ex}{\tiny\bf +}%
\nolinebreak\hspace{-.10em}\raisebox{.4ex}{\tiny\bf +}%
\index{C++@\protect\CC}}


Then you will just write \CC and have it indexed every time.

• That'll save you keystrokes, but, depending on the type of document, it may sacrifice the quality of the index a bit. – Brent.Longborough Aug 20 '14 at 16:23