10

Note: Answers about any of the index-generating packages would be beneficial, such as splitidx or the default makeidx.

I've seen some books with explanatory text on their index page after the Index title but before the actual index list. How can this be done without manually modifying the .idx or .ind files? The command printindex seems woefully unable.

Here's an adequate but regrettably small example:

enter image description here

Here's a MWE that uses the package makeidx.

\documentclass[12pt]{book}
\usepackage{makeidx}\makeindex
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\index{1@One makeidx entry!With a subentry}

%How to put text on the following index page?
\printindex
%Be sure to run: makeindex <filename>


\end{document}

Here is a MWE that uses the package splitidx and creates two indices:

\documentclass[12pt]{book}
\usepackage[split]{splitidx}\makeindex
    \newindex{firstindex}
    \newindex{secondindex}
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\sindex[firstindex]{1@One splitindex entry!Using firstindex}
\sindex[secondindex]{Another splitindex entry!Using secondindex}

%How to put text on the following index pages?
\printindex[firstindex][A splitindex: firstindex]
\printindex[secondindex][A splitindex: secondindex]
%Be sure to run: makeindex <filename>-firstindex; makeindex <filename>-secondindex

\end{document}
BMS
  • 915

1 Answers1

8

Use the package imakeidx instead of makeidx. This package is more robust and allows:

  • Index in several columns with \makeindex[columns=n]

  • Text before of Index and after of title with \indexprologue{Text ...}. This command must be put exactly before of \printindex.

  • Run makeindex automatically.

  • Support for splitindex script by Markus Kohm.

  • Other options described in its documentation.

Example MWE

\documentclass[12pt]{book}
\usepackage{imakeidx}\makeindex
\usepackage{lipsum}

\begin{document}

\lipsum[1] \index{1@One entry!With a subentry}~\index{a@Other entry} \indexprologue{\noindent How to put text on the following index page?} \printindex

\end{document}

It is also possible generate several indexes with this package. In this case you must load the package with the splitindex option and run makeindex on <filename>-firstindex and <filename>-secondindex (if firstindex and secondindex are the names of your indexes). Or to do this automatically running pdflatex with --enable-write18 or -shell-escape options.

Note: It isn't necessary to put a name to all indexes (as in splitidx). Simply leave the "main" index nameless and name the others. And use \makeindex (without arguments for the main index) and \makeindex[name=...,title=...] for the other indexes. Observe the example

\documentclass[12pt]{book}
\usepackage[splitindex]{imakeidx}
    \makeindex
    \makeindex[name=secondindex,title=Second Index]
\usepackage{lipsum}

\begin{document}

\lipsum[1] \index{1@One splitindex entry!Using firstindex} \index[secondindex]{Another splitindex entry!Using secondindex}

\indexprologue{\noindent How to put text on the following index pages?} \printindex

\indexprologue{\noindent How to put text on the following index pages in the second index?} \printindex[secondindex] %Be sure to run: makeindex <filename>-splitindex; makeindex <filename>-secondindex %Only if you didn't run pdflatex with the --enable-write18 option.

\end{document}

So is created a file <filename>-splitindex.idx for the main index and <filename>-secondindex.idx for the second one. The main index uses \indexname for the Index's title.

Run

pdflatex --enable-write18 <filename>

will do this automatically by you.

\documentclass[12pt]{book}
\usepackage[splitindex]{imakeidx}
    \makeindex[name=firstindex,title=First Index]
    \makeindex[name=secondindex,title=Second Index]
\usepackage{lipsum}

\begin{document}

\lipsum[1] \index[firstindex]{1@One splitindex entry!Using firstindex} \index[secondindex]{Another splitindex entry!Using secondindex}

\indexprologue{\noindent How to put text on the following index pages?} \printindex[firstindex]

\indexprologue{\noindent How to put text on the following index pages in the second index?} \printindex[secondindex] %Be sure to run: makeindex <filename>-firstindex; makeindex <filename>-secondindex

\end{document}

skpblack
  • 8,904
  • 3
  • 31
  • 42