6

I followed the example posted by @Schweinebacke Customizing Index - Adding chapter heading and verse number to index entries and it works great. However I would like to change the appeareance of index. To show the change I am attaching an image with this mail.

I would like to align the columns of index, first column left justified, right column right justified and middle column left justified.

I would really appreciate your help enter image description here

1
  • any expectation/restrictions on the size of the material in each "column", e.g., can one assume that everything is always fitting onto a single line? Feb 23, 2012 at 20:39

1 Answer 1

4

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:

enter image description here

2
  • I tried to apply same concept to get text chapter # Page numbers. it worked great however I got all zeros for page numbers. All I wanted to change was verse numbers to page numbers.
    – Aku
    Feb 24, 2012 at 0:45
  • Works great, however its consuming the entire page width, is there a way to keep the standard index format of two columns, that looks lot more like a book style. if required you can reduce the font size to put two columns per page, like the usual index output.
    – Aku
    Feb 24, 2012 at 0:50

You must log in to answer this question.

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