I'm trying to include an index at the end of my document using \usepackage{imakeidx} and the \makeindex and \printindex commands.

I would like the index to mention the section number as well, for instance:

37. Section 37 Make a mention of the word index


index, s37, p1

Is this possible, and if yes, how?

  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jun 29 '14 at 3:47

Using xindy as index generator, it is possible to write additional information to index file, such as the section number s37,p100 or similar.

The relevant command is imki@wrindexentrysplit, the format can be specified in its 3rd argument, see the lines there.

However, xindy does not recognize this format initially, so there has to be an additional xindy module, the usage of it is specified within the options=-M sectionindex_sectionpage.xdy option to \makeindex.

I used a forloop to generate some dummy sections with dummy index entries, just for convenience. The index shows the format s{sectionnumber},p{pagenumber} .




% Global redefinition of indexentry to use section, then page%

\makeindex[options=-M sectionindex_sectionpage.xdy]



\forloop{loopcounter}{1}{\number\value{loopcounter} < 13}{%
\section{Section \Numberstring{loopcounter}}



This is a dummy index entry to \textbf{\Numberstring{loopcounter}}\index{\Numberstring{loopcounter}}




The file sectionindex_sectionpage.xdy contains

( require "tex/inputenc/latin.xdy")
( require "texindy.xdy" )
( require "page-ranges.xdy") 
( require "book-order.xdy")

( define-location-class "sectionfirstthenpages"
                        ("alpha" :sep "" "arabic-numbers" :sep "," "alpha" :sep "" "arabic-numbers" ))

enter image description here

|improve this answer|||||
  • can this be done without xindy? just using package index using makeindex. If put \label for each section and put \ref{thatsectionlabel} in index arument it works..but i have many sections in a large document – Levan Shoshiashvili May 20 '15 at 19:35
  • @LevanShoshiashvili: I don't know at the moment, I'll take a look later on – user31729 May 21 '15 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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