5

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?

0

2 Answers 2

6

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.

3
  • tocbibind produces right page number in toc, but it links Index to the previous chapter. Commented Feb 7, 2013 at 19:00
  • @AntonPetrunin The package has [chapter] option that solves this issue.
    – yo'
    Commented Feb 7, 2013 at 19:17
  • \usepackage[chapter]{tocbibind} did not work for me Commented Dec 16, 2018 at 18:03
4

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.

2
  • It gives wrong page number and makes link to the last chapter before Index. Commented Feb 7, 2013 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
    Commented Feb 7, 2013 at 19:30

Not the answer you're looking for? Browse other questions tagged .