Numbering of figures in DocBook

272 views Asked by At

I'm using the Maven docbkx plugin to generate a PDF.

I would like the figures to be numbered as usual sequentially from 1, ignoring any chapters, sections etc.

This doesn't work, as I turned on hierarchical numbering of sections with the configuration parameter sectionLabelIncludesComponentLabel in the pom.xml. Now the first section in chapter 2 is not 1 (as it is by default) but 2.1, as I want.

But as a side effect, the first figure in chapter 2.1 gets the number 2.1, too, and the next figure gets 2.2, so the chapter number is not only prepended to sections, but also to figures (which makes absolutely no sense).

How can I have hierarchical section numbers, but at the same time simple sequential figure numbering?

[Edit]

Looks like sectionLabelIncludesComponentLabel has nothing to do with it. Even if I turn it off, the figure titles are prefixed with the chapter number.

1

There are 1 answers

0
mzjn On BEST ANSWER

There is no parameter to switch on the wanted behaviour, but it can be done by customizing a template in common/labels.xsl (the number part of a title is called a "label" in DocBook-XSL).

You will need to create a customization layer and add the following to it:

<xsl:template match="db:figure" mode="label.markup">
  <xsl:choose>
    <xsl:when test="@label">
      <xsl:value-of select="@label"/>
    </xsl:when>
    <xsl:otherwise>
     <!-- Use simple sequential numbering within a book -->
     <xsl:number format="1" from="db:book" level="any"/> 
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>