I am trying to create an index manually, where each index entry refers to a page and the corresponding chapter. So basically I am creating my own idx file, then use Latex's MakeIndex functionality to get ind file, and then produce the corresponding PDF file.
So my tex file simply looks like:
\documentclass[a4paper,10pt]{extarticle}
\usepackage[10pt]{extsizes}
\usepackage{makeidx}
\begin{document}
\printindex
\end{document}
My idx file has entries as follows:
\indexentry{Aims of regulation}{3}
\indexentry{Cost of regulation}{4}
Now I was wondering how to edit my indexentry command to allow for a chapter number, so the index looks something like:
Aims of regulation, …… Ch5.p3
Cost of regulation, ……. Ch5.p4
I was trying to use:
\indexentry{Aims of regulation}{Ch5.p3}
\indexentry{Cost of regulation}{Ch5.p4}
but that doesn't work since I assume only numbers are accepted.
My aim is simply to make use of MakeIndex so a sorted .ind file is created automatically, which I then simply print to a PDF file.
Any suggestions?
Thanks.
Best Answer
Makeindex supports composite page numbers. The following example uses the first part for the chapter number and the second part for the page number. A style file for makeindex is created to add macro markup that is defined to analyze the page number to add the formatting (adding
Ch
, dot, andp
).Raw index file
\jobname.idx
:Sorted and formatted index file
\jobname.ind
:Remarks:
\jobname.mst
is automatically loaded by makeindex.encap
and page range features of makeindex.\romannumeral-
\x` trick removes a starting space.