Next / Previous / Contents / NM Tech homepage

11.4. PDF section and subsection headings

In stylesheet versions before 1.68.0, the body text was not considered to be indented. To make headings stand out, they were negatively indented by setting the title.margin.left parameter to a negative value.

However, in our transition from DocBook 4.2 to 4.3, we moved from stylesheet version 1.65.1 to 1.69.1. Currently, the body indentation is set by body.start.indent (see Section 11.1, “General page layout”), and titles are considered to be not indented. Therefore, we do not set the title.margin.left parameter anymore.

The section.autolabel variable turns on section numbering, so that for example a subsection will have a number like 3.4.

zdp_fo.xsl
<!--Prepend the chapter number to section numbers.-->
<xsl:param name="section.label.includes.component.label" select="1"/>

<!--section.autolabel: Use I.J.K section numbering-->
<xsl:param name="section.autolabel" select="1"/>

Next we set a number of properties of section titles. The section.title.level1.properties attribute set is for the largest, top-level titles. It inherits all the other attributes from the section.properties attribute set that defines properties common to section titles of all levels.

zdp_fo.xsl
<!--section.title.level1.properties: Level 1 titles-->
<xsl:attribute-set name="section.title.level1.properties"
                   use-attribute-sets="section.properties">

The TCC style mandates a fairly thick (1-point) rule under first-level section titles. This effect is achieved by using the border-bottom properties. Because the default border style is none, we have to specify both a style (solid) and a width.

zdp_fo.xsl
  <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
  <xsl:attribute name="border-bottom-width">1pt</xsl:attribute>

The first section title property we have to adjust is the font size. In the stock stylesheets, top-level titles have a font size of “mag step 4” (where each mag step is a factor of 1.2 larger than the previous size, so mag step 2 is 1.2 × 1.2 or a factor of 1.44), second-level titles are mag step 3, and third-level titles are mag step 2. This seems to us a bit larger, so we'll go down one whole mag step. The base value to which these magnifications are applied is body.font.master, which defaults to 10.

zdp_fo.xsl
  <xsl:attribute name="font-size">
    <xsl:value-of select="$body.font.master * 1.728"/>
    <xsl:text>pt</xsl:text>
  </xsl:attribute>
</xsl:attribute-set>

The attribute sets for second- and third-level headings are the same except for the font size multiplier.

zdp_fo.xsl
<!--section.title.level2.properties: Level 2 titles-->
<xsl:attribute-set name="section.title.level2.properties">
  <xsl:attribute name="font-size">
    <xsl:value-of select="$body.font.master * 1.44"/>
    <xsl:text>pt</xsl:text>
  </xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="section.title.level3.properties">
  <xsl:attribute name="font-size">
    <xsl:value-of select="$body.font.master * 1.2"/>
    <xsl:text>pt</xsl:text>
  </xsl:attribute>
</xsl:attribute-set>

In the stock stylesheets, the space before level 1 and level 2 section titles was about the same as the space after those titles. This violates one of Robin Williams's style rules: titles should be closer to the sections that follow them than to the sections before, so that they have a visual association.

The stock values of space-before for section titles are 0.8, 1.0, and 1.2 ems, for minimum, optimum, and maximum, respectively. We'll roughly double these values. This template comes from fo/param.xsl.

zdp_fo.xsl
<!--section.title.properties: Appearance of section titles-->
<xsl:attribute-set name="section.title.properties">
  <xsl:attribute name="font-family">
    <xsl:value-of select="$title.font.family"/>
  </xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <!-- font size is calculated dynamically by section.heading template -->
  <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  <xsl:attribute name="space-before.minimum">1.8em</xsl:attribute>
  <xsl:attribute name="space-before.optimum">2em</xsl:attribute>
  <xsl:attribute name="space-before.maximum">2.2em</xsl:attribute>
  <xsl:attribute name="text-align">left</xsl:attribute>
  <xsl:attribute name="start-indent">
    <xsl:value-of select="$title.margin.left"/>
  </xsl:attribute>
</xsl:attribute-set>