I'm only going to offer you an outline of the solution, you should then customize it according to your taste.
Basic approach is to provide a style file for makeindex so that you effectively get an .ind
file containing a longtable
environment. The parts of an index line then have to be separated not by comma but by &
and the lines should end in \\
.
The &
between "verse" and "chapter" would be generated by the index command itself, e.g. from the other question:
\newcommand*{\vindex}[2]{%
\setcounter{verse}{#2}%
\sindex[vrs]{#1& \currentchapter}% % <---
}
And we also need to load the packages we use later:
\usepackage{longtable,array}
The rest is done by the special style for makeindex (that should be saved in a file, say verse.ist
:
preamble "\\section*{\\indexname}
\\newcommand\\ignoreNL[1]{} % throw away \\ after new group
\\setlength\\LTleft{0pt}
\\setlength\\LTright{0pt}
\\begin{longtable}{l!{\\extracolsep{\\fill}}lr}"
postamble "\\end{longtable}"
item_0 "\\\\\n" % \\ between entries
delim_0 "&" % & between text and "page" number
group_skip "\n \\\\[5pt] \\ignoreNL" % extra space 5pt between groups
Notes:
I used \section*
for the heading, but with the book class you will probably want \chapter*
and you may or may not want to add "running headers" and a TOC entry.
One problem with index style files is that there is no handle to add something after the page number only between entries (item_0
). However, if there is a group change we may want to add extra space and if we do this then we would get \\[5pt] \\
which isn't we want. So we additionally add \ignoreNL
which simply gobbles the following \\
.
Applying the index style file
I found it surprisingly difficult to make splitindex work with TeXworks, in fact I didn't manage if a style file was to be used. So in the end I used the commandline for that. Here is how this looks:
splitindex.exe -m "makeindex -s verse.ist" tmp
with "tmp.tex" being my test file. One more run of LaTeX and we get:
