Search This Blog

Sunday, March 30, 2014

Any advice: LaTeX and makeindex

Readers - For a long time now I have been working on a very large LaTeX document (actually built out of a number of sub-documents) that I will discuss further in later posts.  I greatly desire to create an index for this document, and I know about the LaTeX package \makeindex.   The question is, does anyone know of a good frontend application that can make the creation of the index less tedious?  The brute force approach would require me to go through the document(s) by hand and insert a \makeindex tag every time a term that I wish to index appears.  For an index containing a couple of hundred entries, this looks excruciating.  What I would love is an application where I identify the terms for which I want index entries, and it then automatically inserts the appropriate tags (in a smart way, not putting tags inside LaTeX equations, for example).  While this would be imperfect, it would be easier to start from an over-complete index and pare down or modify than to start from scratch.  Yes, I am sure I could use perl or another scripting language to make something, but I'd rather not reinvent the wheel if someone has already solved this problem.  Thanks for any suggestions.

3 comments:

Vijay said...

Hi Doug,

Take a look at this.

http://gna.org/projects/latex-indexbuild/

I use it regularly and it works very well. You can just download the perl script and run. No need to install.

Douglas Natelson said...

Vijay: Thanks - that looks very promising!

Unknown said...

Hello Prof. Natelson,

That might be too nerdy of an answer, but what about using the brute force method in a terminal:


TermsToIndex="alpha beta gamma orwhatever"
for file in `ls ./*.tex`
do
for term in $TermsToIndex
sed -i "s/ $term / \index{$term} /g" $file
done
done