docbook-apps

  • 1.  Setting book toc.indent.width for sect1

    Posted 10-13-2012 07:33
      |   view attached
    In a book toc, I need to set the first-level sections listed under each
    chapter against the left margin of the toc.

    The screenshot showing the sections listed under Chapter 2 is what I'm
    trying to achieve with a customization of toc.indent.width (I think
    that's what I need anyway).

    I used a single toc.indent.width value (29pt), and in the FO I changed
    the margin-left for the fo:block that has a chapter id number, to give
    it a negative value for toc.indent.width. The fo code is:

    <fo:blockid="toc.d0e1.chap2"margin-left="-29pt">
    <fo:basic-linkinternal-destination="sec2.1">
    <fo:list-block></fo:list-block>
    provisional-label-separation="1mm"provisional-distance-between-starts="10mm">
    <fo:list-item>
    <fo:list-item-labelend-indent="label-end()">
    <fo:block></fo:block>

    Setting the value of -29pt once for each chapter will set the left
    margin correctly for all section entries listed in each chapter.

    But how do I apply that margin-left value in the stylesheets? I tried
    modifying the relevant code in thetemplate
    <xsl:templatematch="d:book|d:setindex"mode="toc">.

    The fo:block in that template seems obvious, but that oddly didn't apply
    the left-margin to the FO:

    <fo:blockid="toc.{$cid}.{$id}" margin-left="-29pt">
    <xsl:attributename="margin-{$direction.align.start}">
    <xsl:call-templatename="set.toc.indent"></xsl:call-templatename="set.toc.indent">


    Thanks in advance!

    --
    *Dave Gardiner*


    </xsl:attributename="margin-{$direction.align.start}"></fo:blockid="toc.{$cid}.{$id}"></xsl:templatematch="d:book|d:setindex"mode="toc"></fo:list-item-labelend-indent="label-end()"></fo:list-item></fo:basic-linkinternal-destination="sec2.1"></fo:blockid="toc.d0e1.chap2"margin-left="-29pt">


  • 2.  Re: [docbook-apps] Setting book toc.indent.width for sect1

    Posted 10-13-2012 09:40
    On 10/13/2012 08:33 AM, Xmplar wrote:
    > In a book toc, I need to set the first-level sections listed under each chapter
    > against the left margin of the toc.
    >
    > The screenshot showing the sections listed under Chapter 2 is what I’m trying to
    > achieve with a customization of toc.indent.width (I think that’s what I need
    > anyway).
    >
    > I used a single toc.indent.width value (29pt), and in the FO I changed the
    > margin-left for the fo:block that has a chapter id number, to give it a negative
    > value for toc.indent.width.

    Using pt as length values may be interesting when viewed in a PDF viewer.

    What happens when I zoom in to make the document readable (to me)?
    Do the values remain constant? I.e. distort wrt remainder of the document?

    If your base font is 10pt, try some value relative to that, 3em or
    something, to see if the spacing remains constant (relatively)

    Just a thought.


    regards

    --
    Dave Pawson
    XSLT XSL-FO FAQ.
    http://www.dpawson.co.uk



  • 3.  Re: [docbook-apps] Setting book toc.indent.width for sect1

    Posted 10-13-2012 13:41
    Problem solved. I realized that when I added parts to a book, the
    toc.indent.width value was doubled for the section entries - it's
    cumulative. I found the right template that affects the toc.indent.width
    for chapters, and needed to customize it for books both with and without
    parts. Here is my code (with a new variable "toc.indent.width.sections"
    expressed in points, which provides left margin for all section, sect1,
    etc... titles):

    <xsl:template match="d:preface|d:chapter|d:appendix|d:article"
    mode="toc">
    <xsl:param name="toc-context" select="."/>

    ...

    <xsl:if test="$toc.section.depth > 0
    and $toc.max.depth > $depth.from.context
    and $nodes">

    <xsl:choose>

    <xsl:when test="parent::d:part">
    <fo:block id="toc.{$cid}.{$id}"
    margin-left="-{$toc.indent.width}pt+{$toc.indent.width.sections}pt">


    <xsl:apply-templates select="$nodes" mode="toc">
    <xsl:with-param name="toc-context" select="$toc-context"/>
    </xsl:apply-templates>
    </fo:block>
    </xsl:when>

    <xsl:otherwise>
    <fo:block id="toc.{$cid}.{$id}"
    margin-left="{$toc.indent.width.sections}pt">


    <xsl:apply-templates select="$nodes" mode="toc">
    <xsl:with-param name="toc-context" select="$toc-context"/>
    </xsl:apply-templates>
    </fo:block>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:if>
    </xsl:template>



    On 13-10-12 6:33 PM, Xmplar wrote:
    >
    > In a book toc, I need to set the first-level sections listed under
    > each chapter against the left margin of the toc.
    >
    > The screenshot showing the sections listed under Chapter 2 is what I'm
    > trying to achieve with a customization of toc.indent.width (I think
    > that's what I need anyway).
    >
    > I used a single toc.indent.width value (29pt), and in the FO I changed
    > the margin-left for the fo:block that has a chapter id number, to give
    > it a negative value for toc.indent.width. The fo code is:
    >
    > <fo:blockid="toc.d0e1.chap2"margin-left="-29pt">
    > <fo:basic-linkinternal-destination="sec2.1">
    > <fo:list-block
    > provisional-label-separation="1mm"provisional-distance-between-starts="10mm">
    > <fo:list-item>
    > <fo:list-item-labelend-indent="label-end()">
    > <fo:block
    >
    > Setting the value of -29pt once for each chapter will set the left
    > margin correctly for all section entries listed in each chapter.
    >
    > But how do I apply that margin-left value in the stylesheets? I tried
    > modifying the relevant code in thetemplate
    > <xsl:templatematch="d:book|d:setindex"mode="toc">.
    >
    > The fo:block in that template seems obvious, but that oddly didn't
    > apply the left-margin to the FO:
    >
    > <fo:blockid="toc.{$cid}.{$id}" margin-left="-29pt">
    > <xsl:attributename="margin-{$direction.align.start}">
    > <xsl:call-templatename="set.toc.indent"/>
    > </xsl:attribute>
    >
    > Thanks in advance!
    >
    > --
    > *Dave Gardiner*
    >