Docbook - HTML - Numbering the table of content(TOC)

By xngo on February 24, 2019

To number the table of content(TOC) so that looks like this:

1.  Chapter    
1.1  Section
1.2  Section          
1.2.1 Section        
2.  Chapter              
2.1  Section
2.2  Section



Add the following in your customization.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
  <xsl:import href="lib/docbook-xsl/html/docbook.xsl"/>
 
  <xsl:param name="generate.toc">
    appendix  toc,title
    article/appendix  nop
    article   toc,title
    book      toc,title,figure,table,example,equation
    chapter   title
    part      title
    preface   title
    qandadiv  toc
    qandaset  toc
    reference toc,title
    sect1     toc
    sect2     toc
    sect3     toc
    sect4     toc
    sect5     toc
    section   toc
    set       toc,title
  </xsl:param>
  <xsl:param name="section.autolabel" select="1"></xsl:param>
  <xsl:param name="section.label.includes.component.label" select="1"></xsl:param>
 
</xsl:stylesheet>

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.