One could use the package makeidx together with the program makeindex to generate index table in his/her LaTeX document, automatically. They are great tools, however, I'm not satisfied with the default outputting style.

The default style uses a comma as separative sign of index entry name and the page number(s), and what I need is something like the default table of contents --- using leaders as separator and referring to the section numbers (but not page number).

I've searched and read lots of posts on Internet, and this post seems to be the answer to the question. However, I don't know how to migrate them into my document. For these reasons, could I ask for a step by step answer?

2 Answers 2


In order to use section numbers instead of page numbers it is necessary to redefine the way, the index entry is written to \jobname.idx. That is basically easy, if the package imakeidx is used.

In its manual, imakeidx the author writes, that \imki@wrindexentry should be redefined to apply for other styles. Looking into the package, there is a similar command used with \thepage as argument, so redefined it, using \thesection.

However, makeindex as external processor complains about the new format if \thesection writes its numbers as 1.1 etc., i.e. with dots. Using xindy solves this problem, by applying a new alphabet or location-class, this is done in sectionindex_xindy.xdy, as well as removing the , separator and inserting ----- instead.

Content of sectionindex_xindy.xdy

(markup-locclass-list :open " ----- " :sep "")

( define-location-class "numericsections"
                        ("arabic-numbers" :sep "." "arabic-numbers"))

( define-location-class "numericchapteralphasections"
                        ("arabic-numbers" :sep "." "ALPHA"))



%\usepackage{hyperref}% Leads to linking to wrong positions%

% Global redefinition of indexentry to section instead of page%


%redefine the index write command to use figure number instead of section number


%redefine the index write command to use table number instead of section number


\makeindex[options=-M sectionindex_xindy.xdy]




\caption{A first figure with index entry, say Figure\index{Figure!First}}

\section{First section of chapter~\arabic{chapter}}

Here is a table (well, the environment actually)

A & dummy & table \tabularnewline
\caption{A table with some index entry in it: \index{Table}{First}}
See also the keyword Index\index{Index}


Index\index{Index} and its usage\index{usage}

\caption{A dummy figure with an index entry, say DummyFigure\index{Figure!DummyFigure}}




In order to make this work for figures/tables, I just redefined the command again within wrappers for figure and table environment. You have redefine \thefigure and \thetable explicitly, since it seems, that they introduce a trailing \relax command just before the figure/table number.

Please note, that this does not work correctly with hyperlinks so far,regarding the figure/table index entries.

Enabling --shell-escape is mandatory.

enter image description here

  • Hello @Hupfer! Thank you for your answer, the result of your codes is almost what I need. However, by leaders in the question, I mean a series of $\cdot$, but not -----, and not dividing into two columns is necessary. For these two reasons, I'd like to replace -----, in the file sectionindex_xindy.xdy, with \xleaders\hbox{$\cdot$}\hfill, and to add columns = 1 into the options list of command \makeindex. Now, everything works fine! Thank you again!
    – HongyanLu
    May 26, 2014 at 5:57
  • @HongyanLu: Nice that it was almost complete, but I was not sure about any issue of your request. I will change my provided solution later on
    – user31729
    May 26, 2014 at 6:46
  • Hello @Hupfer! I just got another solution and made a new answer to this question. I think that is a fantastic method, and hope you will enjoy it. :)
    – HongyanLu
    May 28, 2014 at 2:48

Well, I find another solution that is more elegant than Hupfer's, from my point of view.

Since makeindex(.exe) could only handle positive number as page numbers, and would complain about something like 1.1, which is, in general, the form of subsection numbers, we have two choices: bypassing this obstruction by using other indexing program, such as xindy (which is described by Hupfer); encoding 1.1 in base-100 number system, i.e. 101, before the .idx file is processed by makeindex, and modifying the .ind file before being loaded by \printindex.

To achieve this, I mean, the second choice, I borrowed some code from [email protected] and [email protected]. And finally, I got the following:

preamble = "\begin{theindex}\def\seename{See}\def\alsoname{Also see}\providecommand*\indexgroup[1]{\indexspace\item \textbf{#1}\nopagebreak}"

postamble "\n\n\\end{theindex}\n"

group_skip "\n\n  \\indexspace\n\n"

delim_0 "\\xleaders\\hbox{$\\cdot$}\\hfill "
delim_1 "\\xleaders\\hbox{$\\cdot$}\\hfill "
delim_2 "\\xleaders\\hbox{$\\cdot$}\\hfill "

headings_flag 1
heading_prefix "\\mbox{}\\hfill{}\\textbf{"
heading_suffix "}\\hfill\\mbox{}"

numhead_positive "Number"
numhead_negative "Number"
symhead_positive "Symbol"
symhead_negative "Symbol"

\makeindex[options = -s indexsec.ist, columns = 1]

  \the\numexpr#1 * 100 + #2\relax}
  \divide\idx@high by 100



    {\PackageWarning{imakeidx}{Undefined index file `#1'}%




foo, bar, baz


hoge, fuga, piyo



BTW, in this case, enabling --shell-escape is mandatory, too.

  • 1
    A nice idea, but what if there are 100 or more figures/tables in a chapter ( a rare case, admitted ;-)) A little example: Say, the thefigure is provideds 1.100, so this would lead to 1*100 + 100 = 200, divided by 100, finally resulting in 2, all done by \idx@encode and \idx@decode, leaving a index 'page reference' to 2.0
    – user31729
    May 28, 2014 at 3:47
  • @Hupfer: Yeah, you got it. That's the very limitation of the solution. However, no proper remedy comes into my mind. Sadly. :(
    – HongyanLu
    May 28, 2014 at 12:16

You must log in to answer this question.

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