TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the next defined command:


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:


   M Item

I cannot understand what I do wrong?

share|improve this question
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
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.