MakeIndex, Nomenclature, Glossaries and Acronymsduplicate index entries...not

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
Post Reply
mcswell
Posts: 9
Joined: Sun Apr 08, 2012 4:15 pm

duplicate index entries...not

Post by mcswell »

Does anyone have an example of using makeindex with both a page number and a 'seealso', or with both a 'see' and a 'seealso'? I seem to be doing s.t. wrong, because makeindex complains at me when I try to do this, and it doesn't output what I expect.

Some details on what I'm trying to do: I am trying to use makeindex (v2.5) to create an index, and for the most part it works fine. I do have a couple glitches, however, with index entries like the ff.:

Code: Select all

\index{Demonstratives|see{Pronouns, demonstrative}}
\index{Demonstratives|seealso{Determiners}}
The auto-generated indexentry's are similar:

Code: Select all

\indexentry {Demonstratives|see{Pronouns, demonstrative}}{98}
\indexentry {Demonstratives|seealso{Determiners}}{98}
The intended output would be something like:
Demonstratives, see Pronouns, demonstrative; see also Determiners
But what I get instead is a warning:
## Warning (input = pashtoGrammar.idx, line = 292; output = pashtoGrammar.ind, line = 469):
-- Conflicting entries: multiple encaps for the same page under same key.
and the output
Demonstratives, , see Pronouns, demonstrative
That is, the 'seealso' command is ignored (except that it apparently outputs a comma), and only the 'see' command results in useful output. (Also, if that stray comma is indeed coming from the 'seealso', then why is it before the output of 'see' instead of after?)

A similar output results from the pair:

Code: Select all

\indexentry {Verbs!subjunctive}{199}
\indexentry {Verbs!subjunctive|seealso{Irrealis}}{199}
namely the same warning msg, and only one of the two entries gets output, whereas I wanted something like
Verbs, subjunctive, 199; see also Irrealis
What do I need to do to get two index "entries" under one heading? Isn't this what 'seealso' is for?

In summary: what (I think)I need is a good example of the use of 'seealso' together with a 'see' or a page number; the documentation for makeindex seems not to have that, just examples of 'see' or 'seealso' by themselves.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
mcswell
Posts: 9
Joined: Sun Apr 08, 2012 4:15 pm

duplicate index entries...not

Post by mcswell »

Hmm, no comment. Ok, here's a minimal example:

Code: Select all

\documentclass{report}
\usepackage{makeidx}
\makeindex
\begin{document}
Here is some text, without which the index doesn't get built.
\index{Pronouns}
\index{Determiners}
\index{Irrealis}

\index{Demonstratives|see{Pronouns}}
\index{Demonstratives|seealso{Determiners}}

\index{Verbs}
\index{Verbs|seealso{Irrealis}}

\printindex
\end{document}
The result is the ff. warnings:
## Warning (input = indexBug.idx, line = 4; output = indexBug.ind, line = 3):
-- Conflicting entries: multiple encaps for the same page under same key.

## Warning (input = indexBug.idx, line = 7; output = indexBug.ind, line = 16):
-- Conflicting entries: multiple encaps for the same page under same key.
done (18 lines written, 2 warnings).
Again, my question is how I get an output looking something like:
Demonstratives, see Pronouns, see also Determiners
Verbs, 1, see also Irrealis
(without the warnings :-)).
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

duplicate index entries...not

Post by nlct »

You could define a new command that combines both things:

Code: Select all

\documentclass{report}
\usepackage{makeidx}
\makeindex

\newcommand{\seeandalso}[3]{\see{#1}{#3}; \seealso{#2}{#3}}
\newcommand{\pageandalso}[2]{#2; \seealso{#1}{#2}}

\begin{document}
Here is some text, without which the index doesn't get built.
\index{Pronouns}
\index{Determiners}
\index{Irrealis}

\index{Demonstratives|seeandalso{Pronouns}{Determiners}}

\index{Verbs|pageandalso{Irrealis}}

\printindex
\end{document}
Regards
Nicola Talbot
mcswell
Posts: 9
Joined: Sun Apr 08, 2012 4:15 pm

duplicate index entries...not

Post by mcswell »

Hmmm, so if I'm understanding correctly (...), if I want both a 'see' and a 'see also', or both a page # and a 'see also', then the correct syntax is to preceded the 'seealso{}' with a '\' instead of a '|'. Like this:

Code: Select all

    \documentclass{report}
    \usepackage{makeidx}
    \makeindex
    \begin{document}
    Here is some text, without which the index doesn't get built.
    \index{Pronouns}
    \index{Determiners}
    \index{Irrealis}
    \index{Demonstratives|see{Pronouns}}\seealso{Determiners}
    \index{Verbs}\seealso{Irrealis}}
    \printindex
    \end{document}
In other words, since I always use 'seealso' in combination with a 'see' or a page number, I should really treat it as a \ command, not as a | command that goes inside the arg of a \index{} command. That was not obvious from the documentation and examples I found on the web, which seems to assume that an index item may contain just a 'see also' (which seems odd: "also" besides what?).

Thanks for putting me on the right track!
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

duplicate index entries...not

Post by nlct »

The vertical bar | within \index tells makeindex to construct a command from the following word and append the page number as the final argument, so if \index{foo|textbf} appears on page 2, makeindex sets the relevant location to \textbf{2}. Both \see and \seealso have two arguments. The first is the argument you use in \index and the second is the page number, which is ignored by default. So, if you have the following on page 1:

Code: Select all

\index{Demonstratives|see{Pronouns}}
The location in the index becomes \see{Pronouns}{1}

If you want to explicitly use those commands, you need to remember to supply a dummy second argument.

Code: Select all

\see{Pronouns}{X} \seealso{Determiners}{X}
All that will do is insert the text at that point in the document, independent of the index.

(The words "see" and "see also" are stored in \seename and \seealsoname, which are used by \see and \seealso.)

An alternative to the \seeandalso command I used in my previous message is to just list all the cross-referenced terms in one go:

Code: Select all

\index{Demonstratives|see{Pronouns, Determiners}}
Regards
Nicola Talbot
Post Reply