Robert Stayton - 2017-02-04

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

           + padding-corresponding + border-corresponding-width

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).