2

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

C++ appearing first in index

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

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

2 Answers 2

5

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.

1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .