Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Code:

\documentclass{article}

\usepackage{index}
\usepackage{lipsum}
\makeindex

\begin{document}

\section{\index*{Hello World}}

Hello World

Some text about \index*{foo}.

\lipsum[1-15]

Hello World.

\printindex

\end{document}

Output (Index):

foo, 1 Hello World, 1

Problem Statement: The other occurrences of "Hello World" are missed-out in the index.

  • I have not included the other occurrences of "Hello World" under the \index{} tag.

  • But I expect that this way I have declared a key-word to the index.

  • LaTeX should take care of future references of "Hello World" itself.

Is there any way (without using any tcl script) that once I specify a keyword using \index{}, the next occurrences of this word (if located on a different page) should be automatically entered in the index?

share|improve this question
1  
The question is interesting and I am sure you are not the first one which such a question. Unfortunately it isn't possible without an specific script (My information). –  Marco Daniel Aug 26 '12 at 12:33
8  
i think the answer is, in the general case, no. there are reasons for not including some instances of particular terms in an index, so at least those would have to be marked to not be indexed. this is so subjective that i doubt an algorithm could be devised (even with a non-tex script) in an acceptable length of time. –  barbara beeton Aug 26 '12 at 12:37
5  
To write a really good index is a true art form and not easy. It makes no sense to include all occurrences of a term in the index. The index should lead you quickly to arrive at a meaningful place in the document. This must specifically select. There are people who earn a lot of money writing a good index for a finished book or manuscript. It is and I think it will be a handmade thing. –  Kurt Aug 26 '12 at 13:47
add comment

1 Answer 1

up vote 6 down vote accepted

I completely agree with barbara’s objection. I too had the idea of automatically indexing important terms and wrote a simple script. Of course things like index all occurrences of “beautiful necklace” are easy to do. You only need a search-and-replace post-processing script, which encloses beautiful necklace with the indexing and highlighting macros of your choice.

Doing it in TeX itself on the other hand, is nearly impossible, although I don't know what e.g. LuaTeX’s abilities provide. But after all, you are post-processing your TeX code in any case, at least with your compiler (e.g. pdflatex, often more steps are needed). So it seems straight forward to me, to use another script in between.

Now like barbara noted, there may be times where you don't want the replacement to happen at all places. Figuring those out can get rather complicated and even not automatically solvable.

A bigger hindrance still, is that often those indexed terms do not present themselves uniformly in the document. For example you may somewhere talk about a beautiful necklace and later say This necklace is golden, which makes it very beautiful. Here I would index beautiful only, referring to beautiful necklace. Detecting such instances requires and thus is as hard as understanding natural language.

In my experience the indexed terms do mostly appear in some modified form. That is why the most simple solution, which ignores this fact and would be doable, is of no use.

share|improve this answer
1  
The justification provided by all of you is correct. Now I too agree to this point.Thanks ! –  Sandeep Singh Aug 26 '12 at 15:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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