This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Section Numbering in Preface Arabic instead of Roman
- From: Bob Stayton <bobs at sco dot com>
- To: Sean Wheller <seanwhe at yahoo dot com>
- Cc: docbook-apps at lists dot oasis-open dot org
- Date: Tue, 21 Oct 2003 08:43:41 -0700
- Subject: Re: [docbook-apps] Section Numbering in Preface Arabic instead of Roman
- References: <20031021121108.47782.qmail@web41606.mail.yahoo.com>
On Tue, Oct 21, 2003 at 05:11:08AM -0700, Sean Wheller wrote:
> Hi,
>
> Docbook XML 4.2
> Docbook XSL 1.60.1
> Xerces J 2.5.0
> Xalan J 2.5.1
> Apache FOP
> SuSE 8.2
>
> When I transform to PDF the TOC shows page numbers,
> for each section, in Arabic as apposed to Roman, while
> the page numbers within the sections are Roman.
>
> Is this standard or can I force Roman in this part of
> the TOC.
I'm not sure I'm understanding the question here.
Are you asking how to number the pages in a Preface
with arabic instead of roman numerals?
It is common practice to number the first page of the
content as page "1". A preface generally is not
considered part of the "content", so it gets roman
numerals so that the first chapter can start on "1".
But styles vary. There is no parameter to change
the preface to arabic page numbering, it requires
a customization. First, you want to customize the
template named 'page.number.format'. The original is in
fo/pagesetup.xsl, and looks like this:
<xsl:template name="page.number.format">
<xsl:param name="element" select="local-name(.)"/>
<xsl:choose>
<xsl:when test="$element = 'toc'">i</xsl:when>
<xsl:when test="$element = 'preface'">i</xsl:when>
<xsl:when test="$element = 'dedication'">i</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:template>
Change this line:
<xsl:when test="$element = 'preface'">i</xsl:when>
to:
<xsl:when test="$element = 'preface'">1</xsl:when>
That's the easy part. But if you do just that, then your
preface will continue the number sequence from the TOC but
with arabic numbers (..., iii, iv, 5, 6 etc.). and chapter
1 will restart the numbering on page 1 again. You also
need to restart numbering in the preface and not in
the first chapter.
So you also need to customize the templates matching
on preface and on chapter, which are located in
fo/component.xsl. In the preface template, you want
to change:
<xsl:if test="$double.sided != 0">
<xsl:attribute name="initial-page-number">auto-odd</xsl:attribute>
</xsl:if>
to:
<xsl:attribute name="initial-page-number">1</xsl:attribute>
and in the chapter template you want to change:
<xsl:choose>
<xsl:when test="not(preceding::chapter
or preceding::appendix
or preceding::article
or preceding::dedication
or parent::part
or parent::reference)">
<!-- if there is a preceding component or we're in a part, the -->
<!-- page numbering will already be adjusted -->
<xsl:attribute name="initial-page-number">1</xsl:attribute>
...
to add a "preceding::preface" test:
<xsl:choose>
<xsl:when test="not(preceding::chapter
or preceding::appendix
or preceding::article
or preceding::dedication
or parent::part
or preceding::preface
or parent::reference)">
<!-- if there is a preceding component or we're in a part, the -->
<!-- page numbering will already be adjusted -->
<xsl:attribute name="initial-page-number">1</xsl:attribute>
...
If you have more than one preface (which is possible),
then you need to do a similar preceding::preface test
in the preface template as well.
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
The SCO Group fax: (831) 429-1887
email: bobs@sco.com
To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.