I have a LaTeX document featuring these two index entries:
\index{Farbmodell!$\text{LCh}_{ab}$|main}
\index{Farbmodell!$\text{LCh}_{ab}$}
While being "identical" in my view, there are two distinct entries created in the .ind file:
\item Farbmodell
\subitem $\text {LCh}_{ab}$\hspace{1em}\dotfill\hspace{1em}61
\subitem $\text{LCh}_{ab}$\hspace{1em}\dotfill\hspace{1em}\main{39}
|main just indicates the main index entry, using \newcommand{\main}[1]{\textbf{#1}}. I don't understand where these extra spaces come from.
LaTeX packages being used are:
\documentclass[a4paper,twoside]{report}
\usepackage{german}
\usepackage[latin1]{inputenc}
\usepackage{a4}
\usepackage{makeidx}
\usepackage{showidx}
\usepackage{amsmath}
\usepackage{url}
\usepackage{graphicx}
\usepackage{ifthen}
%
\makeindex
\begin{document}
On output, the relevant index part looks like this: 
The first index was entered directly within a section that is part of a chapter, while the second index was entered inside a caption within a table within a section within the appendix. That caption (inside table after tabular) looked like this:
\caption[Pr... im $\text{LCh}_{ab}$ Farbmodell]%
{\label{\Lt{PRMG}}Pr... im $\text{LCh}_{ab}$ Farbmodell%
\index{Farbmodell!$\text{LCh}_{ab}$}
nach \cite[Table~10, S.~15]{ICC.1:2010}}
a4package is obsolete and deprecated and likewisegerman: for the first usegeometrywith suitable parameters, for the latter\usepackage[german]{babel}(orngermanif you use “neue Rechtschreibung”). – egreg May 06 '19 at 21:36\item Farbmodell \subitem $\text{LCh}_{ab}$\hspace{1em}\dotfill\hspace{1em}1, \main{1}. So still: Where do the extra spaces come from? – U. Windl May 06 '19 at 22:37\indexoutside\caption. – egreg May 06 '19 at 22:45\indeximmediately after the ndex term. So instead of moving the\indexpast the caption, I copied it past the caption: Now I have one\indexadded correctly, and the other wrongly (as stated in the question). So where do these extra spaces come from? – U. Windl May 06 '19 at 22:56\indexreads its argument verbatim which means that it behaves differently if used in the argument of any other command. Normally the extra spaces don't matter but if you have the same entry you need to always be in a command argument or always not. – David Carlisle May 06 '19 at 23:02\text {LCh}and\text{LCh}are the same thing in TeX, but not for themakeindexprogram? If so that would sound like a bug in themakeindexprogram to me. I consider to postprocess the.indoutput to "fix" these problems. I'd prefer that over moving the\indexelsewhere. – U. Windl May 06 '19 at 23:13