2

I am writting on a scientific paper with genealogical content. Therefore, many many names occur in my file. Hence, I made an index of all names with imakeidx. Now to my problem:

Sometimes, two persons have the same name and occur on the same page of the pdf-file. Therefore, the entry with this name occurs only once in the index. But I want that EVERY person mentioned in my paper to be in the index. Is there a possibility for that?

Here is my minimal latex code:

\documentclass[10pt,a4paper]{book}
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=50mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[english]{babel}

\usepackage{imakeidx}
\makeindex[name=A,title={index of mentioned persons},columns=2] 

\begin{document}
John Doe\index[A]{John Doe}\newline
John Doe\index[A]{John Doe}


\printindex[A] 
\end{document}

The output of this example is then something like

John Doe, 1

But I want something like

John Doe, 1, 1

EDIT: Please dont question the reason why I need it in that way. I know it looks strange. I just need it for a certain statistical evaluation.

10
  • 4
    If they are two people, their names should be somehow distinguished; if not, what information would the double number add?
    – egreg
    Commented Dec 6, 2019 at 12:33
  • The reader knows that there are two people with exactly the same name..... My data includes around 5000 people..... It is sometimes the case that there are people with exactly the same name.... I want that the index is like an overview of all people mentioned in the document
    – B.Hueber
    Commented Dec 6, 2019 at 12:35
  • 1
    You could facilitate the \index{john_doe_1@John Doe} trick to differentiate between the different persons of the same name. But that will not eliminate the general problem. I do agree with @egreg, that giving an identical page number won't help the reader but confuse him.
    – Jan
    Commented Dec 6, 2019 at 12:42
  • 2
    If the index doesn't show which is which, how does it help. If I see "John Doe, 1" and "John Doe, 1" in the index, how does that help me any more than seeing it one time: if I am just looking for a name, that's all you tell me anyway, and the second entry is redundant pedantry. If there is some other distinguishing feature (e.g. "John Doe (born 1900)" "John Doe (born 1967)" that might be useful: but then the entries will be distinguished anyway. Commented Dec 6, 2019 at 12:55
  • 1
    @Udalricus.S. If you just need it for you, then use the .idx file directly. You can sort it with any external utility such as Perl or Python.
    – egreg
    Commented Dec 6, 2019 at 13:35

1 Answer 1

4

You should have an .ind and an `.idx file. Look for the "duplicate" names in the .ind file, which is in alphabetical order, and observe the page numbers that are duplicated, and also any additional page numbers.

Makeindex has a "dumb" ASCII sort. If entries aren't exactly the same, spaces and all, they'll be sorted separately, so the solution is usually to get rid of "extra" spaces.

Look for the names in the .idx file, which is sorted in page number order. Since the entries are in braces, it will be easy to see anomalous spaces.

Now go into the text file, locate the entry that doesn't match, and fix it. Fix any other entries that appeared on the "extra" line in the index so you don't need to go through this procedure again. Do this for all duplicate names, Then rerun.

By the way, you won't ever get a listed entry

John Doe, 1, 1

All instances on the same page will be listed under a single page number.

2
  • Sample index entry: 'event 28, 29, 29, 29, 29, 51, 55, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 64, 64, 66, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, 69, 70, 70, 71, 71, 71, 71, 71'. I am trying to find a way to avoid the duplicated page numbers, which are apparently all too possible. I also have a minimal example in case you're curious ;).
    – cfr
    Commented Sep 10, 2023 at 2:20
  • I suspect it is the dumbness of the sort which causes this and that the same page number doesn't appear the same to makeindex, but I'm not sure what to do about it.
    – cfr
    Commented Sep 10, 2023 at 2:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .