This is a spin-off of bug [#1389].
While I was writing an example DocBook article file for testing bug [#1389], I found that <index> part of the test article file has very odd indentation in PDF output:
DocBook:
<para>
<indexterm><primary>Apple</primary></indexterm><indexterm><primary>Banana</primary></indexterm><!--
--><indexterm><primary>Citrus</primary></indexterm><indexterm><primary>Durian</primary></indexterm><!--
--><indexterm><primary>Eggplant</primary></indexterm><indexterm><primary>Fig</primary></indexterm><!--
--><indexterm><primary>Grape</primary></indexterm><indexterm><primary>Honeydew</primary></indexterm><!--
--><indexterm><primary>Imbe</primary></indexterm><indexterm><primary>Juniper</primary></indexterm><!--
--><indexterm><primary>Keylime</primary></indexterm><indexterm><primary>Longan</primary></indexterm><!--
--><indexterm><primary>Mangosteen</primary></indexterm><indexterm><primary>Nutmeg</primary></indexterm><!--
--><indexterm><primary>Olive</primary></indexterm><indexterm><primary>Papaya</primary></indexterm><!--
--><indexterm><primary>Quandong</primary></indexterm><indexterm><primary>Rambutan</primary></indexterm><!--
--><indexterm><primary>Strawberry</primary></indexterm><indexterm><primary>Tamarind</primary></indexterm><!--
--><indexterm><primary>Ugni</primary></indexterm><indexterm><primary>Vanilla</primary></indexterm><!--
--><indexterm><primary>Watermelon</primary></indexterm><indexterm><primary>Yangmei</primary></indexterm><!--
--><indexterm><primary>Zwetschge</primary></indexterm><!--
-->This is an example paragraph marked with a lot of index terms.
</para>
<index/>
PDF:
Example Article With Index
Table of Contents
Index.................................................... 1
This is an example paragraph marked with a lot of index terms.
Index
A
Apple, 1
B
Banana, 1
C
Citrus, 1
D
Durian, 1
E
Eggplant, 1
F
Fig, 1
G
Grape, 1
H
Honeydew, 1
I
Imbe, 1
J
Juniper, 1
.
.
.
.
From the PDF output, you would see that index section has following characteristics:
The the first problem makes index part look (obviously) broken and inconsistent with other contents.
Example affected DocBook article, XSL-FO intermediate, PDF rendering, HTML rendering, and build logs are attached as misindentedindex.zip. Example DocBook book with the same content is also provided in the same ZIP file for comparison.
This problem does not affect <book> document and any HTML rendering of <article> document.
Note: To work around this problem, one can disable content indenting of entire article by setting XSLT property body.start.indent to 0pc.
DocBook XML DTD: 4.2
DocBook XSL: 1.79.1 (source)
XSLT Processor: XSLTproc 1.1.26-14.1 (debian)
XSL-FO Processor: Apache FOP 2.1 (binary)
System: Debian GNU/Linux 7.0 Wheezy i386
Thanks for pointing this out. On first examination it appeared as if the FO output was correct and the formatting wrong. The FO output specifies both margin-left="0pt" and start-indent="0pt" on the index section labels. So why were they indented? Because of a really arcane rule in the XSL-FO spec about the interaction of margin-left and start-indent on the same block. The clearest explanation comes from a support page at Antenna House that says:
<quote>
First of all, when margin-left and start-indent are specified at the same time, the specification of start-indent is disregarded, and then start-indent is calculated by the following expression under the condition described as "the formatting object does not generate a reference area" in "5.3.2 Margin, Space, and Indent Properties" in the W3C Recommendation for XSL-FO.</quote>
start-indent = inherited_value_of(start-indent) + margin-corresponding
The inherited start-indent is that of the article's page-sequence flow, which is by default set to 4pc. By discarding the start-indent on the block, it got the inherited start-indent. An article is processed as a single page-sequence, so the index is in that page-sequence (which is why it isn't two-column; that requires a new page-sequence). A book, however, starts a new page-sequence for an index, setting the flow start-indent to zero, so the inherited start-indent in a book is also zero.
The best solution is to omit the margin-left property on the index section labels, and then the block's start-indent="0pt" is used. I will make that change for the next release of the stylesheet.
With the current stylesheet release, a customization is required to patch this, but there is a further complication with that. The margin-left property is specified in the stylesheet's attribute-set named 'index.div.title.properties' (see fo/param.xsl). A customization of an attribute-set will merge specifications, but it cannot cause a previously specified attribute to be omitted entirely. So the solution in this case is actually to specify a margin-left="-({$body.start.indent})" to negate the inherited start-indent. However, that would not work in a book's index. So a customization patch would have to look like this:
<xsl:attribute-set name="index.div.title.properties">
<xsl:attribute name="margin-left">
<xsl:choose>
<xsl:when test="ancestor::d:article">
<xsl:value-of select="-({$body.start.indent})">
</xsl:value-of></xsl:when>
<xsl:otherwise>0pt</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:attribute-set>
(you would omit the "d:" namespace in the test since you are using DocBook 4).