5

I'm trying to number the index section in my document. If I use only tocbibind it works perfectly, but once I add idxlayout, it doesn't work. idxlayout doesn't have a numindex option like tocbibind.

Here is a MWE:

\documentclass[12pt]{article}

\usepackage{makeidx}
\makeindex

\usepackage[numindex]{tocbibind}
\usepackage[totoc]{idxlayout}

\begin{document}

\tableofcontents

\section{Test}

Test\index{test}

\printindex

\end{document}

How to add the number to the index section and keep idxlayout?

4

Changing the load order of tocbibind and idxlayout won't work because both packages redefine the theindex environment, so whichever package is loaded later will disable the features of the former.

I didn't include an option to number the index in idxlayout because I regard it as bad from a typographic point of view. If you must, patch the internal \ila@prologue macro and remove the totoc option.

(Note: For the book and report standard classes and for the memoir class, replace \section*/\section with \chapter*/\chapter in the example below. A different patching approach would be needed for the KOMA-Script classes.)

\documentclass[12pt]{article}

\usepackage{makeidx}
\makeindex

\usepackage[numindex]{tocbibind}
\usepackage{idxlayout}

% \usepackage{etoolbox}% already loaded by `idxlayout`
\makeatletter
\patchcmd{\ila@prologue}{\section*}{\section}{}{}
\makeatother

\begin{document}

\tableofcontents

\section{Test}

Test\index{test}

\printindex

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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