# Adding a chapter title for indices (multind) on the same page as the first index is printed

I am trying to add a chapter title 'Indices' before the first multind index is printed. However, printindex flushes the page so if I do it, I will get the title, rest of the page empty, and the first index. I would like to have the 'Indices' title and then the first index printed immediately below it, then the second index beginning normally with a flushed page.

-------------    -------------    -------------    -------------
|           |    |           |    |           |    |           |
|  Indices  |    |  Names    |    | ---- ---- |    |  Places   |
|           |    | ---- ---- |    | ---- ---- |    | ---- ---- |
|           |    | ---- ---- |    | ---- ---- |    | ---- ---- |
|           |    | ---- ---- |    | ---- ---- |    | ---- ---- |
|           |    | ---- ---- |    |           |    | ---- ---- |
|    124    |    |    125    |    |    126    |    |    127    |
|-----------|    |-----------|    |-----------|    |-----------|


I want to achieve:

-------------    -------------    -------------    -------------
|           |    |           |    |           |    |           |
|  Indices  |    | ---- ---- |    | ---- ---- |    |  Places   |
|           |    | ---- ---- |    |           |    | ---- ---- |
|  Names    |    | ---- ---- |    |           |    | ---- ---- |
| ---- ---- |    | ---- ---- |    |           |    | ---- ---- |
| ---- ---- |    | ---- ---- |    |           |    | ---- ---- |
|    124    |    |    125    |    |    126    |    |    127    |
|-----------|    |-----------|    |-----------|    |-----------|


I am using book. Any help will be much appreciated.

MWE:

\documentclass{book}

\usepackage{multind}
\makeindex{names}
\makeindex{places}

\usepackage{lipsum}

\begin{document}

\chapter{Chapter one}
\index{names}{John}\index{places}{London}
\lipsum
\index{names}{Tim}\index{places}{York}

\chapter{Chapter two}
\index{names}{John}\index{places}{York}
\lipsum
\index{names}{Tim}\index{places}{London}

\chapter*{Indices}
\printindex{names}{Index of names}
\printindex{places}{Index of places}

\end{document}

-

multind.sty defines \printindex as

\def\printindex#1#2{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
\columnseprule \z@ \columnsep 35pt
\newpage \twocolumn[{\Large\bf #2 \vskip4ex}]
\markright{\uppercase{#2}}
\@input{#1.ind}}


and both \newpage and \twocolumn force a new page. In the following example I redefined \printindex suppressing \newpage and the use of \twocolumn; I used the multicol package instead to produce a two-column layout; also, instead of simply {\Large\bf #2 \vskip4ex} I used \section* to typeset the titles.

\documentclass{book}
\usepackage{multind}
\usepackage{multicol}
\usepackage{lipsum}

\makeindex{names}
\makeindex{places}

\makeatletter
\def\printindex#1#2{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
\columnseprule \z@ \columnsep 35pt
\csname phantomsection\endcsname
\section*{#2}
\markright{\uppercase{#2}}
\begin{multicols}{2}
\@input{#1.ind}%
\end{multicols}%
}
\makeatother

\begin{document}

\chapter{Chapter one}
\index{names}{John}\index{places}{London}
\lipsum
\index{names}{Tim}\index{places}{York}

\chapter{Chapter two}
\index{names}{John}\index{places}{York}
\lipsum
\index{names}{Tim}\index{places}{London}

\chapter*{Indices}
\printindex{names}{Index of names}
\newpage
\printindex{places}{Index of places}

\end{document}


An image of the firs page of the indices:

Perhaps you could consider using another more modern package to build your indices; splitindex seems a good option.

-
+1 multicol can't be avoided, because \twocolumn adds a new page anyway. – Andrew Swann Oct 28 '12 at 21:56
Thank you Gonzalo, this works brilliantly. I understand the solution and will try to learn from it. Also, thank you for your advice concerning multind. After this project, I am going to drop it in favour of a more modern package. – Kajetan Wandowicz Oct 28 '12 at 22:39

A solution with a more modern package than multind:

\documentclass{book}

\usepackage{imakeidx}
\makeindex[name=names,title=Index of names]
\makeindex[name=places,title=Index of places]

\newcommand{\startindices}{%
\chapter*{Indices}
\let\latexcleardoublepage\cleardoublepage
\def\cleardoublepage{%
\def\cleardoublepage{%
\global\let\cleardoublepage\latexcleardoublepage}}%
}

\usepackage{lipsum}

\begin{document}

\chapter{Chapter one}
\index[names]{John}\index[places]{London}
\lipsum
\index[names]{Tim}\index[places]{York}

\chapter{Chapter two}
\index[names]{John}\index[places]{York}
\lipsum
\index[names]{Tim}\index[places]{London}

\startindices
\printindex[names]
\printindex[places]

\end{document}


Note the different syntax for the \index entries, which might be inconvenient for you, if you have already written many of them. In this case, adding

\let\imkiindex\index
\renewcommand\index[1]{\imkiindex[#1]}


before \end{document} allows you to keep multind syntax for index entries.

It shouldn't be a big problem to modify the \makeindex and \printindex commands.

The advantage in using imakeidx is that you don't have to rememeber to run MakeIndex, as the package does it for you. It also features the possibility of adding the indices to the table of contents, with

\makeindex[name=names,title=Index of names,intoc]
\makeindex[name=places,title=Index of places,intoc]

-
Thank you egreg! I am going to learn more about both imakeidx and splitindex (which Gonzalo has suggested) before I typeset anything with indices again. – Kajetan Wandowicz Oct 28 '12 at 22:42