3

Before I index 200 pages of my thesis manually, I need to ask if there is a better way to do this? For example, can I specify a file which contains keywords whose locations are to be indexed?

DKS
  • 1,309
  • You can run a 'regex search and replace' if your editor supports it. This would simply replace all occurrences of keyword with \index{keyword}keyword – Sean Allred Jan 11 '14 at 18:42
  • 1
    You're indexing your thesis? – Joseph Wright Jan 11 '14 at 18:51
  • @SeanAllred That's giving you a concordance, not an index. Behind every indexed word, there is decision to index the word and under which key. An index shall be a help for the reader, not just another way to add more pages to a manuscript. I remember a text book written in Word Perfect, which had the possibility to make an automatic concordance, where the concordance covered every word in the book. The author was to lazy to make a list of stop words. Of course, there was an impressing number of pages in the book. – Sveinung Jan 11 '14 at 18:51
  • @Sveinung I think Sean is assuming that there will be some selectivity in the choice of keywords, not a bulk indexing of every single word. – Joseph Wright Jan 11 '14 at 19:02
  • 1
    @SeanAllred 's search and replace could be done with a script (python, perl, awk, ...) that read the file of words to be indexed. – Ethan Bolker Jan 11 '14 at 19:07
  • 1
    @JosephWright Still I am of the opinion that it is impossible to make good and useful index automatically. At my university the best students was hired as paid assistants to professors, to build indexes and bibliographies, and check references in their books. But of course, I left the university in 1985. – Sveinung Jan 11 '14 at 19:12
  • @Sveinung I wasn't disputing that, I was simply observing that his approach would at least produce an index rather than something else. My understanding on indexing is that you have to hire professionals. – Joseph Wright Jan 11 '14 at 19:14
  • 1
    @EthanBolker It reminds me of a former colleague that gladly use a week to make and debug a script to process text that I use half an hour to fix manually. Sorry, forgot the smiley :-) – Sveinung Jan 11 '14 at 19:14
  • I would like it if the regex prompted before replacing any entry. I don't want a fat thesis which nobody dares to open, but a few pages of Index towards the end will help the readers (in my opinion). – DKS Jan 11 '14 at 19:17
  • 1
    @user42569 Well, then you have to write a front end program. I suggest hand craft. Nothing beat the human brain in the end. Read the thesis once more, and index the proper word in a proper way. It will bring the thesis to a new level :-) – Sveinung Jan 11 '14 at 19:20
  • 2
    I agree with @Sveinung in concept and practice—indexes are only useful if every entry is meaningful. That said, this is screaming Emacs' M-x query-replace-regexp. It will be a long process, but somewhat automated. – Sean Allred Jan 11 '14 at 19:44

1 Answers1

4

This can easily be achieved using Emacs and RefTeX. With your cursor in your thesis, press M-x reftex-index-visit-phrases-buffer (Alt-X …) or press C-c | (Control-C, pipe). This will open up the RefTeX Index Phrases file (a rip file). Simply add all of your index terms there in the following format:

i <TAB> term   <TAB> index entry
i <TAB> term 2 <TAB> index entry 2
...

Syntax highlighting will tell you if the line is in the correct syntax. Once you've finished this, press C-c C-a. RefTeX will jump back to your thesis and begin asking you which ones to replace.


I agree with the manual in not doing this all in one go. This will take more time than you think, so refer to the manual to see how to do chunks at a time. The manual also describes all of the different functionality the rip file has; I gave only the most basic example above. RefTeX is great.

Edit

If your thesis is split into multiple files, you might also want to use AUCTeX, a huge corpus of excellent functionality for LaTeX within Emacs. You can install both AUCTeX and RefTeX using M-x package-list. (M-x is Alt-X.)

Sean Allred
  • 27,421