Copyright (C) 2000-2012 |
Whole document tree Authoring for IndexingThere are two parts to building an index automatically, creating the index terms and incorporating the generated index into your document. Creating Index TermsThe generated index is constructed from IndexTerms in your document. DocBook IndexTerms are not part of the flow. <para> This paragraph contains an interesting thing<indexterm id="thing"> <primary>thing</primary><secondary>interesting</secondary></indexterm> that will appear in the index. </para> It is not absolutely necessary to provide an ID for each index term, but the performance of the print backends may degrade significantly if you have a large number of index terms that do not have IDs. Incorporating the IndexThe index will be generated as a separate file. You must arrage to have this file incorporated into your document. The easiest way to do this is by file entity reference. At the top of your document, add an internal subset that defines the index file entity: <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V3.1//EN" [ <!ENTITY genindex.sgm SYSTEM "genindex.sgm"> ]> <book> ... &genindex.sgm; <!-- Put this after the end tag of the last chapter or appendix, or --> <!-- wherever you want the index to appear. It must be a valid location --> <!-- for an index. --> </book> Before you can process this document, you must make sure that genindex.sgm exists. This is a chicken and egg problem, but it can be solved with the collateindex.pl command: perl collateindex.pl -N -o genindex.sgm The -N option creates a new index; -o indentifies the name of the output file. This name must be the same as the name you specified in the internal subset. Creating an IndexCreating an index is a multi-step, two-pass process:
DrawbacksAny generated index is perhaps better than none, but there are still a few things that cannot be accomplished:
It is possible that the TeX backend could be made smart enough to do these things automatically. (Sebastian will probably kill me for suggesting that). For the RTF backend, at least in MS Word, it's probably possible to write a WordBasic macro that would automatically fix the index. (If someone does, please pass it along). |