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.

Possible Duplicate:
Problem with the numeration appearing in the table of contents
Index is incorrectly listed in the table of contents

I am using

\usepackage{madeidx}
\makeindex

I added entry of index in ToC with

\addcontentsline{toc}{chapter}{Index}
\printindex

This way I can get entry of Index in ToC, how ever page number it is printing is one less than actual page number.

How to get correct page number?

share|improve this question

marked as duplicate by lockstep, egreg, Paulo Cereda, tohecz, Joseph Wright May 5 '12 at 20:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

Solution I: Prepend \addcontentsline with \clearpage (or \cleardoublepage in twoside and openright):

\clearpage
\addcontentsline{toc}{chapter}{Index}
\printindex

Solution II: Use the tocbibind package that manages automatic inclusion of Table of Contents, Index, Bibliography, ... into the Table of Contents. The package behaviour can be controlled by some parameters, see the documentation at the link above.

share|improve this answer
    
tocbibind produces right page number in toc, but it links Index to the previous chapter. –  Anton Petrunin Feb 7 '13 at 19:00
    
@AntonPetrunin The package has [chapter] option that solves this issue. –  tohecz Feb 7 '13 at 19:17

Add the following to your document preamble:

\makeatletter
\g@addto@macro{\theindex}{\addcontentsline{toc}{chapter}{Index}}
\makeatother

This inserts your contents-related entry as part of the last things before the index is actually printed.

share|improve this answer
    
It gives wrong page number and makes link to the last chapter before Index. –  Anton Petrunin Feb 7 '13 at 18:58
1  
@AntonPetrunin: I get the correct page number when using a small MWE. If you're using hyperref, you should add \phantomsection before \addcontentsline. –  Werner Feb 7 '13 at 19:30

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