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.

  • 4
    If they are two people, their names should be somehow distinguished; if not, what information would the double number add? – egreg Dec 6 '19 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 – Udalricus.S. Dec 6 '19 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 Dec 6 '19 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. – Paul Stanley Dec 6 '19 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 Dec 6 '19 at 13:35
2

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 well be listed under a single page number.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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