Copyright (C) 2008 by Steve Litt, All rights reserved. Material provided as-is, use at your own risk.
your first C program, 43-44Of course, those entries weren't even one page long. They were just short sections that happened to fall across page boundaries. They ugly-up the index. I decided I wanted such 2 page ranges to look like this instead:
your first C program, 43So I wrote a Ruby program to go through the mydoc.idx file, spitting out entries with ranges 2 or less pages, and began to manually change every range, within the LyX document, to non-range single entries.
makeindex -o test_index.ind -s mybookis.ist mybook.idxIn the preceding, mybook.idx is a no-format list of index entries created by running latex on your book's LaTeX file. The test_index.ind file is the LaTeX output file to create a nicely formatted index. If you don't use the -o option, makeindex would default the output file to mybook.ind -- it simply changed the input filename's extension to .ind. The makeindex program also outputs a log file, that defaults to the input filename with the index changed to .ilg. This is handy for debugging. The mybookis.ist file is the style file with which you configure makeindex. The style file is a list of key/value pairs like this:
keyname "value"The value can be on a line below the key name, and the value can take up several lines.
COMMAND | LOCATION | EXPLANATION |
\usepackage{makeidx} | Document preamble | Includes code necessary for indexing functionality |
\makeindex | Document preamble | This command generates the .idx file when the latex command is run on the book's LaTeX file. |
\index{atoms} | Mainmatter | Single page index reference under name atoms |
\index{atoms!carbon} | Mainmatter | Single page index reference to carbon subcategory of atoms. A two level index entry. |
\index{atoms!carbon!diamond} | Mainmatter | Single page index reference to diamond subcategory of carbon subcategory of atoms. A three level index entry. Indices can go only three deep. |
\index{subjectname|(} | Mainmatter | Begining of range index reference under name subjectname. Also works with multilevel index entries. |
\index{subjectname|)} | Mainmatter | End of range index reference under name subjectname.Also works with multilevel index entries. |
\printindex | Backmatter | Insert the index here. |
#!/bin/bash | Bash script |
./mktest.sh rjustWhere mktest.sh is the script and rjust is the LyX file's filename minus the .lyx extension. Look at the resulting PDF, and note the index. Make sure you have some single page entries, some ranges that go past one page border (i.e 11-12), and some ranges that go multiple pages (i.e. 23-27).
suffix_2p "and1more" |
suffix_2p "\\ and\\ 1\\ more" |
Wikipedia, 23 and 1 more, 67 to 69
suffix_2p " " |
preamble |
preamble | Begin HTML doc as usual |
cat rjust.idx | sed -e "s/hyperpage//" | makeindex -s mybook.ist -o temp.htmlYou need to remove from the input file the "hyperpage" commands inserted by the hyperref package. Then the conversion goes as expected and can be viewed in a browser. Note that you still get some \see and \seealso commands, but those can easily be tweaked to their correct format.
makeindex -s mybookis.ist mybook.idxThe default output file is the .idx filename, but with an extension .idn instead of .idx.