There are several parameters that control numbering of chapter and section titles. By default in printed output, chapter titles are numbered but section titles are not. Appendix titles are numbered (with letters) when in a book, but not numbered by default when in an article. 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.fo \ --stringparam chapter.autolabel 0 \ --stringparam appendix.autolabel 0 \ fo/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.fo \ --stringparam section.autolabel 1 \ --stringparam section.label.includes.component.label 1 \ fo/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 3.1.2.1 Context menus sect3 3.2. Selecting sect1 3.2.1 Click and drag 3.2.2 Double click
Section labels in an appendix will use the appendix letter instead of a chapter number.
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 aren't 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).
When producing a book, it is sometimes appropriate to group related chapters into book parts. To do that, you use part
elements in your book
element, and then put your chapter
elements inside your part
elements. Each part has a title, and may have a title page to indicate a new grouping of chapters.
Numbering of book parts is turned on by default, using uppercase roman numerals. You can turn off part numbering by setting the part.autolabel
parameter to zero.
Regardless of whether parts are numbered, you can restart chapter numbering at the beginning of each part. If you want that type of chapter numbering, set the label.from.part
parameter to 1. If you use that option,
you will probably also want to set the component.label.includes.part.label
parameter to 1. That changes the chapter
numbering so the chapters in the first part are numbered I.1, I.2,
I.3, etc., and the chapters in the second part are numbered II.1,
II.2, II.3, etc. If you don't set the second parameter, then your
output will have more than one “Chapter 1” and citations and cross references will be ambiguous. The
parameter similarly modifies appendix numbers.
If you would rather number your parts using arabic numerals instead of uppercase roman numerals, you can't do it with a stylesheet parameter. You have to customize a template in a customization layer. Although customizations are covered later, this one is included here to make it easier to find.
<xsl:template match="part" mode="division.number"> <xsl:number from="book" count="part" format="1."/> </xsl:template>
DocBook XSL: The Complete Guide - 3rd Edition | PDF version available | Copyright © 2002-2005 Sagehill Enterprises |