This question already has an answer here:

I want to have an index entry typeset as $a_\text{T}$, so I issue the command \index{at@$a_\text{T}$}. Each use of this index command creates a separate line in the index. How can I get \makeindex to recognize they all reference the same topic?

My index entries look like this:

enter image description here

marked as duplicate by gernot, Phelype Oleinik, Stefan Pinnow, Zarko, Milo Aug 10 '18 at 15:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Can you show an example? – egreg May 10 '14 at 15:14
  • 1
    I think what @egreg meant was can you provide a minimal working example (MWE)? – Nicola Talbot May 10 '14 at 15:23
  • 2
    For solvers: +\usepackage{amsmath} – Malipivo May 10 '14 at 15:29
  • 2
    @GregH We need some code that shows the problem: I trust you when you say you get duplicate entries, but I can't know how you input them. – egreg May 10 '14 at 15:34
  • 2
    Having answered I remembered having answered before, this is probably a duplicate of tex.stackexchange.com/a/105713/1090 assuming it is the same issue. – David Carlisle May 10 '14 at 15:59

Hard to say as you provided no example but I'd guess you have done this:

enter image description here







One argument is read verbatim and the other not, resulting in an idx file like

\indexentry{at@$a_\mathrm  {T}$}{1}

with different entries. The easiest solution is to wrap both in the same command. If you put \mbox (or anything) around the first \index then the index entries are merged.

  • I noticed when you add \mbox then the next word doesn't get hyphenated. Maybe this is only happening in my setup but be sure to check it out. – Martin Mueller Feb 3 '17 at 9:34
  • a "word" has to be preceded by white space to be considered a word to be tried for hyphenation, so \mbox{} abcdef" would not try hyphenating abcdef` you can use `\mbox{} \hspace{0pt)abcdef" for example @MartinMueller – David Carlisle Feb 3 '17 at 9:43
  • my problem was that i have the index behind the word: "Romeo\indexentry{Shakespeare!Romeo and Juliet}, a play" when used with mbox. When I would add \hspace{0pt} and have a comma afterwards it would move that comma to the next line. – Martin Mueller Feb 3 '17 at 11:11
  • @MartinMueller you have never provided any test file so it is hard to guess what you are doing, but a box after a word does not stop hyphenation, just one before, also you can always use \nolinebreak to prevent a break at the 0pt space, but why are you using \mbox at all? – David Carlisle Feb 3 '17 at 11:51
  • sorry, you're right, I didn't do it properly. I played around with your solution because i have a command \emph{ } within my entry and the whole whitespace-duplicate entries started. but I have it fixed now with splitindex, protected and an additional parenthesis around the \newcommand{\foo}[1]{{\sindex[foo]{#1}} so I just wanted to leave a small comment. – Martin Mueller Feb 3 '17 at 11:58

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