I have a document with hundreds of \index entries. I'm trying to generate the index for some part of the document.
The best I could come up with is to disable the \index command temporarily. I did it like this:
\let\origindex\index
\newcommand\indexoff{\renewcommand\index[2][]{}}
\newcommand\indexon{\let\index\origindex}
I use it like this to generate the index of, say, chapter 2 only:
\indexoff
\include{chapter1}
\indexon
\include{chapter2}
\indexoff
\include{chapter3}
Is there a better or cleaner way? (My experience with this sort of macros is rather limited. I'm not even sure what \let does exactly.)
\letdefines the new command to have the same definition as the old one so it's like going\newcommand\origindex{... whatever the definition of \index is ....}– David Carlisle Jul 04 '12 at 19:44