0

Sorry for any mistakes, this is my first time here. I have about 70 different .pdf files, each in its own directory. Each of course has their own index. What I need is one total index into one separate document.
In case it is relevant, I use MiKTeX and memoir document class. Thanks in advance, Peter.

  • Welcome to TeX.SE :-). – Sebastiano Jan 19 '17 at 11:16
  • I think it should be possible to open each of the individual .ind files which has been generated during the compilation of the relevant .tex file and read the \indexentry as a string and storing all such lines in a single file, but what are the merging rules? If index entry A in file X appears on page 17 and in file Y on page 194, listing both (or more page numbers) is wrong, of course, since the total index does not where the original files came from. – user31729 Feb 3 '17 at 21:29
1

If you're interested in doing this inelegantly and you have .idx files for these .pdfs, this process will work.

  1. Combine the contents of the .idx files into one file, it won’t matter if they are out of order.

  2. Dump this text list into Microsoft word or some other program capable of sorting.

  3. Sort it A-Z using the first field (this, I think, will be an ASCII sort just like in Latex’s indexing)

  4. You get a list with a bunch of things such as : \indexentry{contents}{11}

  5. Find and replace \indexentry{ with \\, leaving you with \\ contents}{11}. Include a space after \\; it should be \\_.

  6. Find and replace { with whatever you want as the gap between the citation and the page numbers, e.g. \hfill or \dotfill, leaving you with \\ contents} \hfill 11}. Be sure to include spaces around your \hfill or whatever you choose.

  7. Now, replace all } with nothing; make sure the Replace box is empty. That should leave you with \\ contents \hfill 11.

  8. From here, I think it really depends on your indexing terms, that is, whether you have lots of parents (e.g. \indexentry{parent!parent!contents}{11}) or sortkeys (e.g. \indexentry{sortkey@contents}{11}). I would expect it to still work though. You can still find and replace parent terms with nothing so you go from \\ parent!contents \hfill 11 to \\ contents \hfill 11.

Caveat 1: Before doing step 8, eliminate any numbers or symbols being used as sortkeys for the parent and then re-sort the list. That is, if you have something left at this point like \\ 01@Genesis!0202 @2:2}{33} you should Find and Replace 01@ (with nothing). At this stage, that should produce \\ Genesis!0202 @2:2 \hfill 33.

Caveat 2: You may have to do some manual deletions if you do have something like \indexentry{01@Genesis!0202 @2:2}{33}. If you have sortkeys that differ from reference to reference (0202 in the example I just gave, rather than 01, since 01 sorts the parent and 0202 sorts the child/subitem) those will require manual deletion.

  1. After you've repeated the Find and Replace to deal with more complicated examples, cut and paste it into your tex editor in an environment with the number of columns you need. (I've never done this, but I’m sure it would be straightforward). Stick a \chapter*{Index} on it and that should be it.

Step 8, and its caveats, would only apply to quite complex indices; I would think regular subject indices don't require that kind of attention.

  • 1
    You might be interested to read mark your inline code I tried to do it for you, but I became confused if you mean the 3 backslashed from the sourcecode of you question or the two ones, which are currently displayed in you question. – user36296 Feb 23 '17 at 13:05
  • I didn't mark it because I figured since I'm talking about working with the text in MS Word it would be confusing to mark it as if it's code. I see now it could be quite the opposite! I'll edit it now. – niesen Feb 23 '17 at 13:11

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.