Chapter and section numbering

There are several parameters that control numbering of chapter and section titles. By default, part and chapter titles are numbered but section titles are not. Appendix titles are numbered with uppercase letters. In the DocBook XSL stylesheets, the number part of a title is called a label.

If you prefer to turn off chapter numbering, then set the chapter.autolabel parameter to zero. If you also want to turn off appendix numbering (A, B, C, etc.), then also set the appendix.autolabel parameter to zero.

xsltproc  --output myfile.html  \
  --stringparam  chapter.autolabel 0 \
  --stringparam  appendix.autolabel 0 \
  html/docbook.xsl  myfile.xml

To turn on basic section numbering, set the section.autolabel parameter to 1. Then your titles will be numbered as follows:

Chapter 3. Using a mouse
1.  Basic mouse actions    sect1
1.1  Left button           sect2
1.2  Right button          sect2
1.2.1 Context menus        sect3
2.  Selecting              sect1
2.1  Click and drag
2.2  Double click

Notice that the section numbers do not include the chapter number by default, so section numbering starts over with each new chapter. If you prefer the section numbers to include the chapter number, then set the section.label.includes.component.label parameter to 1. This assumes that you leave chapter numbering turned on. For example:

xsltproc  --output myfile.html  \
  --stringparam  section.autolabel 1 \
  --stringparam  section.label.includes.component.label 1 \
  html/docbook.xsl  myfile.xml

This results in the following numbering style:

Chapter 3. Using a mouse
3.1.  Basic mouse actions    sect1
3.1.1  Left button           sect2
3.1.2  Right button          sect2 Context menus        sect3
3.2.  Selecting              sect1
3.2.1  Click and drag
3.2.2  Double click

Section titles in an appendix will prepend the appendix letter instead of a chapter number.

Starting with version 1.69.1 of the stylesheets, you can change the numbering style of any of these elements using its parameter. For example, you could use uppercase letters instead of numbers for chapters. You specify the format by using one of the following characters as the autolabel parameter value.

Table 7.1. Number formats for autolabel parameters

Parameter valueNumbering styleExample
1Arabic numerals1, 2, 3, 4, ...
AUppercase letters.A, B, C, D, ...
aLowercase letters.a, b, c, d, ...
IUppercase roman numerals.I, II, III, IV, ...
iLowercase roman numerals.i, ii, iii, iv, ...
١Arabic-Indic numerals١, ٢, ٣, ٤, ...

Here are the default settings for the autolabel parameters:

<xsl:param name="appendix.autolabel" select="'A'"/>
<xsl:param name="chapter.autolabel" select="1"/>
<xsl:param name="part.autolabel" select="'I'"/>
<xsl:param name="reference.autolabel" select="'I'"/>
<xsl:param name="section.autolabel" select="0"/>

Depth of section numbering

You may want to limit the depth of sections that get a section number. If you have deeply nested sections, then the string of numbers in the section label can get quite long. Or perhaps you just want sections at levels 1 and 2 to be numbered, since any lower level sections are not important enough to have a number label.

You can use the section.autolabel.max.depth parameter to control which section levels get a number label. If you set the parameter to 2, then only sections at levels 1 and 2 will have the label. The default value is 8, meaning all section levels have numbering (if it is turned on).