Table of Contents – How to Add Number to Index Printed with \printindex from imakeidx

imakeidxindexingtable of contents

I have almost done with my document, but the problem is that when I print my Index, the table of contents is not showing me the corresponding number (I want to make it as a chapter). So, I used
\makeindex[columns=3, title=Indice Analitico, intoc, options= -s example_style.ist] at the beginning, and then \printindex, but the result inside the toc is not the expected one. Here there is a small example of my issue:

\usepackage{imakeidx}
\makeindex[columns=3, title=Index, intoc, 
           options= -s example_style.ist]
 \begin{document}
 \tableofcontents
 \chapter{First Chapter}
 This is the first \index{first} chapter
 \printindex
 \chapter{Third Chapter}
 \end{document}

So the result in the table of contents is this:
No number 2 before Index

Best Answer

Edit Thanks for the example!

You didn't provide a compilable example, but the case is covered in the package documentation.

Here's an answer assuming that you are using the book class. Meaning that you want the TOC to include a numbered \chapter-level index.

The same holds for the article class, mutatis mutandis (you want the index to be on the \section level).

Disable the option intoc of \makeindex and use instead the option level of \indexsetup. From p. 5 of the documentation:

level which takes as value a sectioning command such as \chapter or \chapter*. Actually any command with an argument will do and will receive the index title as its argument. The default is \chapter* or, if the class doesn’t provide chapters, \section*. If you specify [level] so as to override the default \chapter*, the index title goes directly to the table of contents; in this case do not specify the intoc option.

(emphasis mine.) The default value is the starred version of either \chapter or \section, which produces an unnumbered chapter/section. Change this to the unstarred version.

\documentclass{book}

\usepackage{imakeidx}

\makeindex[columns=3, 
title=Indice Analitico, 
%intoc,             % disable option "intoc"
]

\indexsetup{        % if unspecified, "level" defaults to \chapter* or \section*
level=\chapter      % numbered chapter in book class
%level=\section     % numbered section in article class
}

\begin{document}

\tableofcontents

\chapter{Capitolo Primo}

\index{an item}
\index{another item}

\printindex

\chapter{Capitolo Secondo}

\end{document}

And here's the new TOC.

TOC with numbered index

Related Question