[Tex/LaTex] the proper use of several \seealso in the same index entry with makeindex

indexingwarnings

If one uses

\index{invariant!\relax|seealso{Lorentz invariance}}%
\index{invariant!\relax|seealso{speed of light}}%

in a .tex file, the makeindex program produces a warning in the .ilg file, when it processes the second entry:

## Warning (input = motionmountain-volume4.idx, line = 29; output = motionmountain-volume4.ind, line = 618):
   -- Conflicting entries: multiple encaps for the same page under same key.

What is the proper way to have several \seealso under one entry, without generating any warnings?

Clarification: the result at present is that despite the warnings all the entries get added, in a series that looks like seealso entry1 seealso entry2 etc.

In my dream, the wanted result is that every seealso starts its own subentry, and that no warnings appear.

Best Answer

the following test file produces see also references from entries where multiple targets are combined in a single input. since \seealso omits page numbers, i don't see any reason not to combine the targets. (just don't forget to enclose them in braces, so that \seealso sees them as a single argument.)

this coding will set the see also text as the last second-level entry for the main item. \igobble removes the leading comma and space. it should be trivial to create a simple two-argument command to insert the "extra" coding.

this method produces no warnings, a problem noted in the original question.

\documentclass{article}
\usepackage{makeidx}
\makeindex
\def\igobble#1 {}

\begin{document}

some text\index{a} with some index entries\index{b}
and some\index{c} \emph{see also} entries as well.
\index{a!zzzzz@\igobble |seealso {b, c}}
\index{a!bcd}
\index{c!zzzzz@\igobble |seealso {a, b}}

\printindex
\end{document}

output of example code

thanks to andrew swann for the suggestion to use a plain-style definition that will solve the problem of removing an unwanted space. (my latex friends have been trying to break me of the habit of using plain-style commands. but in some situations, latex(2e) has no satisfactory approach.)

edit:
the op would prefer to have each see also entry on a separate line. this can be done, but requires additional attention, mostly bookkeeping. if the dummy sort field is the same for all see also entries for one main entry, warnings are unavoidable, although the output would be okay. to avoid the warnings, different dummy sort fields can be applied. if doing this, it's necessary to assign them so that the desired final order will be achieved; this is easy enough if all the \seealso entries are located together in the input file.

\documentclass{article}
\usepackage{makeidx}
\makeindex
\def\igobble#1 {}

\begin{document}

some text\index{a} with some index entries\index{b}
and some\index{c} \emph{see also} entries as well.
\index{a!zzzza@\igobble |seealso {b}}
\index{a!zzzzb@\igobble |seealso {c}}
\index{a!bcd}
\index{c!zzzza@\igobble |seealso {a}}
\index{c!zzzzb@\igobble |seealso {b}}

\printindex
\end{document}

output of example code

the choice of the dummy sort field will govern where in the index the entry will be placed. in this example, zzzzx (with x variable) was used to force them to the end. if, instead, they are preferred at the beginning, something like 0 00x can be used, since digits sort before letters, and the likelihood of actual second-level index entries beginning "zero space" is vanishingly small.

Related Question