# Incorrect reflection in Index part

I have the next defined command:

\def\underscore{\_\nobreak\hfil\protect\penalty0\hfilneg}


Then I want to set some text that usese my command into index:

\index{Items! New\underscore\Item}


I get incorrect reflection in Index part of my document:

Items

   M Item


I cannot understand what I do wrong?

-
Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. –  Heiko Oberdiek Nov 13 '12 at 17:12

you probably need to put \protect before \underscore in the \index entry.
commands are expanded when written out to the .idx file, and since the expansion of \underscore contains an @ sign, it won't behave properly when it's read back in. the \protect ensures that the protected command goes into the .idx file as a literal, and will remain so when converted to the .ind file to be used by (la)tex to produce the index.