0

I apologize if this question has been asked in another guise before.

Is it posssible to get a chapter-wise index in Latex? I would like to have a chapter-wise index alongside a global index. The global index should be formed by merging the chapter-wise indices.

Ideally whatever style settings I apply for the global index, I would like to be applied for the local chapterwise indices too.

1

You can use the imakeidx package to create multiple indices. To "merge" the chapter indices and the main index the easiest way would be to add entries to both the current chapter index and the main index whenever you add something to an index. The code below "automates" this for you by defining an \Index command that adds index entries for both the current chapter and the main index. In particular, it is not necessary to specify the chapter index or the main index. The chapter and main indices can then be printed using the \printindex command.

To illustrate what the MWE does here are the indexes that it produces for the second chapter and the main index:

enter image description here enter image description here

Here is the code:

\documentclass{book}
\usepackage{imakeidx}
\makeindex[title=Chapter one index, name=index1]% chapter 1 index
\makeindex[title=Chapter two index, name=index2]% chapter 2 index
\makeindex[title=Full index, name=fullindex]    % main index

% \Index{item}: add "item" to chapter and full index
\newcommand\Index[1]{%
   \index[index\arabic{chapter}]{#1}%  add to chapter index
   \index[fullindex]{#1}%              add to full index
}
\begin{document}

\chapter{Chapter 1}
  Words\Index{one word} \Index{word!one}

\printindex[index1]% print index for chapter 1

\chapter{Chapter 2}
  Words\Index{two words} \Index{word!two}

\printindex[index2]% print index for chapter 2

\printindex[fullindex]% print main index

\end{document}
| improve this answer | |

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.