docbook-apps

  • 1.  Re: [docbook-apps] Customizing Appendix Autolabels

    Posted 04-23-2008 15:01
    
    
    Hi
    This is how I do the Appendix part:

    <!-- set labels for appendices in the table of contents -->
     
    <xsl:template name="toc.line">
     
    <xsl:variable name="id">
       
    <xsl:call-template name="object.id"/>
     
    </xsl:variable>

     
    <xsl:variable name="label">
       
    <xsl:choose>
         
    <xsl:when test="self::d:appendix">
           
    <xsl:call-template name="gentext">
             
    <xsl:with-param name="key">appendix</xsl:with-param>
           
    </xsl:call-template>
           
    <xsl:text> </xsl:text>
           
    <xsl:apply-templates select="."  mode="label.markup"/>
         
    </xsl:when>
         
    <xsl:otherwise>
           
    <xsl:apply-templates select="."  mode="label.markup"/>
         
    </xsl:otherwise>
       
    </xsl:choose>
     
    </xsl:variable>

     
    <fo:block text-align-last="justify"
                text-align
    ="justify"
                end-indent
    ="{$toc.indent.width}pt"
                last-line-end-indent
    ="-{$toc.indent.width}pt">
       
    <fo:inline keep-with-next.within-line="always">
         
    <fo:basic-link internal-destination="{$id}">
           
    <xsl:if test="$label != ''">
             
    <xsl:copy-of select="$label"/>
             
    <xsl:value-of select="$autotoc.label.separator"/>
           
    </xsl:if>
           
    <xsl:apply-templates select="." mode="titleabbrev.markup"/>
         
    </fo:basic-link>
       
    </fo:inline>
       
    <fo:inline keep-together.within-line="always">
         
    <xsl:text> </xsl:text>
         
    <fo:leader leader-pattern="dots"
                     leader-pattern-width
    ="3pt"
                     leader-alignment
    ="reference-area"
                     keep-with-next.within-line
    ="always"/>
         
    <xsl:text> </xsl:text>
         
    <fo:basic-link internal-destination="{$id}">
           
    <fo:page-number-citation ref-id="{$id}"/>
         
    </fo:basic-link>
       
    </fo:inline>
     
    </fo:block>
    </xsl:template>     <!-- END name="toc.line"  -->
    but see the earlier discussion:

    To: "Bob Stayton" <bobs@sagehill.net>
    From: Ron Catterall <ron@catterall.net>
    Subject: Re: [docbook-apps] TOC entries for Apendices
    Cc:
    Bcc:
    Many apologies, the spaces have suddenly appeared  - no idea how, I didn't change anything.  Forget previous email.
    Ron


    Bob
    Thanks very much for the help, I have the Appendix labels almost right now.  The only thing is I can't get a space between Appendix and A etc.
    Ron

    Hi Ron,
    As you discovered, the default output for article/appendix is to include a
    label such as:

    A. Title of the appendix

    I need to update my book.

    Regarding the customization, that variable needs to be inside the
    customization of the template named toc.line.  See the example in the book.

    Also, the call to the template named 'gentext' is what generates the word
    "Appendix" from the local file.  You don't also need the xsl:text element to
    output Appendix.

    Bob Stayton
    Sagehill Enterprises
    DocBook Consulting
    bobs@sagehill.net





  • 2.  Re: [docbook-apps] Customizing Appendix Autolabels

    Posted 04-23-2008 18:47
    
    
    The customization I sent previously was for Docbook 5.  Following is code for DB4.5  Don't know which you need.

    <!-- set labels for appendices in the table of contents -->
     
    <xsl:template name="toc.line">
     
    <xsl:variable name="id">
       
    <xsl:call-template name="object.id"/>
     
    </xsl:variable>

     
    <xsl:variable name="label">
       
    <xsl:choose>
         
    <xsl:when test="self::appendix">
           
    <xsl:call-template name="gentext">
             
    <xsl:with-param name="key">appendix</xsl:with-param>
           
    </xsl:call-template>
           
    <xsl:text> </xsl:text>
           
    <xsl:apply-templates select="."  mode="label.markup"/>
         
    </xsl:when>
         
    <xsl:otherwise>
           
    <xsl:apply-templates select="."  mode="label.markup"/>
         
    </xsl:otherwise>
       
    </xsl:choose>
     
    </xsl:variable>

     
    <fo:block text-align-last="justify"
                text-align
    ="justify"
                end-indent
    ="{$toc.indent.width}pt"
                last-line-end-indent
    ="-{$toc.indent.width}pt">
       
    <fo:inline keep-with-next.within-line="always">
         
    <fo:basic-link internal-destination="{$id}">
           
    <xsl:if test="$label != ''">
             
    <xsl:copy-of select="$label"/>
             
    <xsl:value-of select="$autotoc.label.separator"/>
           
    </xsl:if>
           
    <xsl:apply-templates select="." mode="titleabbrev.markup"/>
         
    </fo:basic-link>
       
    </fo:inline>
       
    <fo:inline keep-together.within-line="always">
         
    <xsl:text> </xsl:text>
         
    <fo:leader leader-pattern="dots"
                     leader-pattern-width
    ="3pt"
                     leader-alignment
    ="reference-area"
                     keep-with-next.within-line
    ="always"/>
         
    <xsl:text> </xsl:text>
         
    <fo:basic-link internal-destination="{$id}">
           
    <fo:page-number-citation ref-id="{$id}"/>
         
    </fo:basic-link>
       
    </fo:inline>
     
    </fo:block>
     
    </xsl:template>
    Ron Catterall, Phd, DSc       email: ron@catterall.net
    Prolongacion de Hidalgo 140http://catterall.net/
    San Felipe del Aguatel: +52 951 520 1821
    Oaxaca      68020Mexicofax: +1 530 348 8309