Features for formatting and styling a back-of-book index
The <index> element is used to produce a back-of-book index. An index can be produced automatically from embedded index terms in chapters and other book components (e.g. preface, appendix). To produce an index in this way, you need to be generally familiar with the indexing functions of DocBook XML (references to online resources are below). The <index> element can contain a title and other descriptive text in <para> tags, but otherwise it is empty (i.e. no other tags are required).
There are embedded index terms throughout the example XML templates you can follow. The main element to define each index term is <indexterm>. Nested within <indexterm> is a <primary> element (to specify text for main headings), and optionally <secondary> (to specify text for subheadings) and <tertiary> (to specify text for subsubheadings) elements. Any text typed inside those three nested elements appears only in the index. For technical reference, read the publication DocBook XSL: The Complete Guide.
The stylesheets p14-endmatter.xsl and c1-commonstyles.xsl have all features and instructions to set up styles for an index.
Index naming. You should give the <index> element a unique xml:id value, such as "endindex". This is because when you produce EPUB and web pages, an HTML file called "index.html" is generated for the home page (title page) of the ebook. You need to differentiate the name of that page from the name of the back-of-book index page, so by giving the <index> element an ID name, it will be generated as a separate web page.
Index ranges. If there is a specific index term that occurs in several subsequent sections of a document, then it is likely to span across pages in an output PDF. The output result of these index terms would be sequential page numbers in the index for that term, such as: 3, 4, 5, 6. Instead of leaving all the individual <indexterm> elements in each section, you can specify one <indexterm> element as the starting point and another <indexterm> as the ending point. The result in the index would be the starting and ending page numbers with a dash, such as 3–6 (set the dash punctuation at stylesheet feature c1-365). Both <indexterm> elements must have the same ID value for the index range to work.
<indexterm class="startofrange" xml:id="informalfigure"> <primary>informalfigure element </primary> </indexterm>
<indexterm class="endofrange" startref="informalfigure"/>For technical reference see http://www.sagehill.net/docbookxsl/GenerateIndex.html#Indexterms.
Preferred pages. You can have specific page numbers highlighted in the output index as preferred pages. This is useful, for example, for highlighting to the reader page numbers in bold text that cover the main discussion of a specific topic. Alternatively, preferred page numbering can be used to highlight page numbers that refer to figures, so as to distinguish index entries for figures apart from entries for body text.
<indexterm significance="preferred"> <primary>text...</primary> </indexterm>For technical reference see http://www.sagehill.net/docbookxsl/FormatPrintIndex.html#FormatIndexEntry.
<indexterm type="people"> <primary>Einstein</primary> </indexterm>
Then switch on the subject-specific index function at stylesheet feature c1-345. When you produce an ebook, a second index with those terms will be generated.
For technical reference see http://www.sagehill.net/docbookxsl/IndexSpecial.html.