Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

So, instead of:

-------------    -------------    -------------    -------------
|           |    |           |    |           |    |           |
|  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}
share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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}}
  \addcontentsline{toc}{section}{#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}}
  \addcontentsline{toc}{section}{#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:

enter image description here

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

share|improve this answer
    
+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
add comment

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]
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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