# Occasionally wrong page numbers for index entries

I have observed that sometimes entries appear in the index not listed with the page number of the page where they are actually displayed, but with the page number increased by one. Apparently that is an annoyance, as it forces me to recheck all my index. I've seen it in footnotes, and solved it by taking the index command out of the footnote. I've also seen it when the word appears in the last paragraph of the page, even if quite a few lines before the end, which I could solve also by setting the marker at the end of the previous paragraph.

Are there some common mistakes leading to the described behaviour which I should avoid, or have I found a bug and should try to find out what it is?

I've tried to make a MWE, but so far failed to reproduce the behaviour.

• The standard indexing commands are quite reliable. So imho your document is doing something wrong. Oct 15, 2015 at 15:54
• i'd be interested in seeing an example with the index term in the last paragraph of a page, where the \index{...} precedes the term to be indexed, as \index{this term}this term. i've seen this happen when this is input as this term\index{this term} for a multi-word term, but not (yet) when the opposite order is used. (i'm trying to write a "comprehensive" guide to reliable indexing. avoiding the off-by-one problem is a major component.) Oct 15, 2015 at 16:00
• It probably won't help but have you tried all the usual: clearing all generated files, and recompiling, including an extra compile when you think you're done? Oct 15, 2015 at 16:01
• it's really difficult to make a MWE in this case and so it's very difficult to say but your second example is really strange. Oct 15, 2015 at 16:03
• @muk.li -- my recommendation is to place \index{...} so that it gives the correct page number. so if the term is a full name, e.g. Albert Einstein, a person looking in the index will look for "Einstein" -- then put \index after the name. if they'd look for the first word of the phrase, e.g. "probability theory", put it before. Oct 15, 2015 at 16:50

based on the discussion in the comments, the following suggestion will not solve all problems, but it should get rid of some of them.

if a term to be indexed falls near the end of a page, it is generally a good idea to place the \index entry before the text string, especially if the term contains more than one word, or might be hyphenated.

in the case of a multi-word term, consider what a person looking in the index will be looking for on the referenced page. if the term is a name, e.g. Albert Einstein, a person looking in the index will look for "Einstein" -- then put \index after the name. if they'd look for the first word of the phrase, e.g. "probability theory", put it before.

i have compiled a document addressing various problems that arise in indexing; it has been posted on the ams web server. (this document is still a work in progress, but is far enough along to be useful. the incomplete portions are marked as such. comments are welcome; the address is included in the introduction.)

the "off by one" problem is encountered quite frequently, and is addressed in my "manual" in greater detail than described above.

• Wow, extremely impressive! Mar 7, 2016 at 1:44
• @WillRobertson -- what, the answer, or the "how to" writeup? Mar 7, 2016 at 2:14
• The howto of course :) I should have been more clear. indexing is one of the less well documented areas of LaTeX I think, great to see such a comprehensive resource. Perhaps TUGboat would be interested in publishing it :) Mar 7, 2016 at 2:54