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}
0

1 Answer 1

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}
4
  • 1
    I hope that the example clarify this. View edit
    – skpblack
    Sep 23, 2014 at 23:17
  • Yes, thank you. And surprisingly I actually didn't have to create any blank \makeindex to get automatic .idx/.ind processing; I just added the --enable-write18 option to my typesetter.
    – BMS
    Sep 23, 2014 at 23:24
  • Very useful package! Allows index generation in a single run.
    – BMS
    Sep 23, 2014 at 23:37
  • Thanks to @egreg, the highest reputation in this community.
    – skpblack
    Sep 25, 2014 at 10:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .