docbook-apps

Re: [docbook-apps] Incorrect page sequence for TOC/Lot andprefacepages withdouble-sided output

  • 1.  Re: [docbook-apps] Incorrect page sequence for TOC/Lot andprefacepages withdouble-sided output

    Posted 04-13-2011 16:51
    > Does that mean for the LOTs, the page sequences for the list of figures, list of
    > tables etc can be handled separately?

    Yes. Each has its own page-sequence. The force.page.count template is called for
    each lot page-sequence with master-reference set to 'lot'. So that template needs to
    know how to detect the last lot for your purposes. That turns out to be a bit tricky.
    You cannot use an XPath expression, because these lots are not in the document but are
    auto generated by the stylesheet.

    In the template named 'make.book.tocs' in fo/division.xsl, there is a test for each
    lot that looks like this:

    <xsl:if test="contains($toc.params,'figure') and .//figure">
    <xsl:call-template name="page.sequence">
    ...

    The $toc.params variable is populated from the 'generate.toc' param that specifies
    which lots to include. The first part of this test checks to see if 'figure' is to be
    included. The second part tests to see if there are any figures in the document. It
    generates a page-sequence only if both cases are true.

    Unfortunately, the force.page.count template does not get passed the name of the
    current lot, only the generic master-reference 'lot'. The context element is 'book',
    so that doesn't help either. So that template does not know which lot it is dealing
    with, so it could not run that test.

    I would suggest instead customizing the 'make.book.tocs' template to generate a single
    page-sequence for all your toc and lots, and then let force.page.count specify 'force'
    for 'lot'. To do a single page-sequence, you would structure the template like this:

    ...
    <xsl:call-template name="page.sequence">
    <xsl:with-param name="master-reference" select="$lot-master-reference"/>
    <xsl:with-param name="element" select="'toc'"/>
    <xsl:with-param name="gentext-key" select="'TableofContents'"/>
    <xsl:with-param name="content">



    <xsl:call-template name="division.toc">
    <xsl:with-param name="toc.title.p" select="contains($toc.params, 'title')"/>
    </xsl:call-template>

    <xsl:if test="contains($toc.params,'figure') and .//figure">
    <xsl:call-template name="list.of.titles">
    <xsl:with-param name="titles" select="'figure'"/>
    <xsl:with-param name="nodes" select=".//figure"/>
    </xsl:call-template>
    </xsl:if>


    </xsl:call-template>

    This is untested, so you may need to insert a forced page-break between lots, because
    the list.of.titles templates assumes each will have its own page-sequence and does not
    do that:

    <fo:block break-after="page"/>


    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    ----- Original Message -----
    From: redlettucemail
    To: docbook-apps@lists.oasis-open.org
    Sent: Wednesday, April 13, 2011 1:54 AM
    Subject: Re: [docbook-apps] Incorrect page sequence for TOC/Lot andprefacepages
    withdouble-sided output


    Bob,
    In one of your posts dated Mar 26, 2009 (Re: [docbook-apps] how to omit blank pages in
    the front matter?) you stated:
    “The preface, toc, and each of the "List Of" are in their own page sequence”
    Does that mean for the LOTs, the page sequences for the list of figures, list of
    tables etc can be handled separately? Looking at my customised xsl:template
    name="force.page.count", I can only see that the LOT is handled as one
    master-reference:
    <xsl:template name="force.page.count">
    <xsl:param name="element" select="local-name(.)"/>
    <xsl:param name="master-reference" select="''"/>

    <xsl:choose>
    <xsl:when
    test="starts-with($master-reference,'listoftitles')">no-force</xsl:when>

    <xsl:when
    test="starts-with($master-reference,'front')">end-on-even</xsl:when>
    <xsl:when test="$element = 'preface'">end-on-even</xsl:when>

    <xsl:when test="$double.sided != 0">end-on-even</xsl:when>

    <xsl:otherwise>no-force</xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    So, if you delete blank pages in the LOTs by using “no-force”, does that delete all
    blank pages from each “List of” in the LOTs? And therefore you cannot force the last
    LOT to end on even? (because that’s what I need). How can I customise a different
    force.page.count for the last LOT to be end-on-even? I’ve attached the output to show
    that I need the Preface to start on an odd page.
    Thanks,
    Dave



    Subject: Re: [docbook-apps] Incorrect page sequence for TOC/Lot and prefacepages
    withdouble-sided output
    From: "Bob Stayton" <bobs@sagehill.net>
    To: "redlettucemail" <redlettucemail@mailscan.acenet.net.au>,
    <docbook-apps@lists.oasis-open.org>
    Date: Tue, 12 Apr 2011 08:50:03 -0700



    Hi Dave,
    Now I'm a bit confused. I thought the goal stated in your earlier mail was to
    eliminate any blank pages for those elements. That's why you were changing 'force' to
    'no-force'. Can you clarify the sequence that you would like to see, and what you are
    actually getting?

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    ----- Original Message -----
    From: redlettucemail
    To: docbook-apps@lists.oasis-open.org
    Sent: Tuesday, April 12, 2011 8:06 AM
    Subject: Re: [docbook-apps] Incorrect page sequence for TOC/Lot and prefacepages
    withdouble-sided output


    Thanks Bob - the code worked. I still have a problem with needing to end the lot on an
    even page, and to also get the following preface to end on even.
    Here is the relevant code:

    <xsl:template name="user.pagemasters">

    <fo:simple-page-master master-name="front-cover"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="-10pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt">
    <fo:region-body
    margin-top="0pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="back-cover"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="0pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt">
    <fo:region-body
    margin-top="-10pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt"/>
    </fo:simple-page-master>



    <fo:page-sequence-master master-name="listoftitles">
    <fo:repeatable-page-master-alternatives>
    <fo:conditional-page-master-reference master-reference="blank"
    blank-or-not-blank="blank"/>
    <fo:conditional-page-master-reference master-reference="lot-odd"
    odd-or-even="odd"/>
    <fo:conditional-page-master-reference
    odd-or-even="even">
    <xsl:attribute name="master-reference">
    <xsl:choose>
    <xsl:when test="$double.sided != 0">lot-even</xsl:when>
    <xsl:otherwise>lot-odd</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </fo:conditional-page-master-reference>
    </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    </xsl:template>


    <xsl:template name="select.user.pagemaster">
    <xsl:param name="element"/>
    <xsl:param name="pageclass"/>
    <xsl:param name="default-pagemaster"/>

    <xsl:choose>
    <xsl:when test="$default-pagemaster = 'lot'">
    <xsl:value-of select="'listoftitles'" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$default-pagemaster"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    Can I insert a blank page if the lot finishes on an odd page?


    Thanks again,


    Dave Gardiner



    -----Original Message-----
    From: "Bob Stayton" <bobs@sagehill.net>
    To: "redlettucemail" <redlettucemail@mailscan.acenet.net.au>,
    <docbook-apps@lists.oasis-open.org>
    Date: Tue, 12 Apr 2011 08:50:03 -0700
    Subject: Re: [docbook-apps] Incorrect page sequence for TOC/Lot and prefacepages
    withdouble-sided output


    Hi Dave,
    Now I'm a bit confused. I thought the goal stated in your earlier mail was to
    eliminate any blank pages for those elements. That's why you were changing 'force' to
    'no-force'. Can you clarify the sequence that you would like to see, and what you are
    actually getting?

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    ----- Original Message -----
    From: redlettucemail
    To: docbook-apps@lists.oasis-open.org
    Sent: Tuesday, April 12, 2011 8:06 AM
    Subject: Re: [docbook-apps] Incorrect page sequence for TOC/Lot and prefacepages
    withdouble-sided output


    Thanks Bob - the code worked. I still have a problem with needing to end the lot on an
    even page, and to also get the following preface to end on even.
    Here is the relevant code:

    <xsl:template name="user.pagemasters">

    <fo:simple-page-master master-name="front-cover"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="-10pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt">
    <fo:region-body
    margin-top="0pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt"/>
    </fo:simple-page-master>

    <fo:simple-page-master master-name="back-cover"
    page-width="{$page.width}"
    page-height="{$page.height}"
    margin-top="0pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt">
    <fo:region-body
    margin-top="-10pt"
    margin-bottom="0pt"
    margin-left="0pt"
    margin-right="0pt"/>
    </fo:simple-page-master>



    <fo:page-sequence-master master-name="listoftitles">
    <fo:repeatable-page-master-alternatives>
    <fo:conditional-page-master-reference master-reference="blank"
    blank-or-not-blank="blank"/>
    <fo:conditional-page-master-reference master-reference="lot-odd"
    odd-or-even="odd"/>
    <fo:conditional-page-master-reference
    odd-or-even="even">
    <xsl:attribute name="master-reference">
    <xsl:choose>
    <xsl:when test="$double.sided != 0">lot-even</xsl:when>
    <xsl:otherwise>lot-odd</xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>
    </fo:conditional-page-master-reference>
    </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    </xsl:template>


    <xsl:template name="select.user.pagemaster">
    <xsl:param name="element"/>
    <xsl:param name="pageclass"/>
    <xsl:param name="default-pagemaster"/>

    <xsl:choose>
    <xsl:when test="$default-pagemaster = 'lot'">
    <xsl:value-of select="'listoftitles'" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$default-pagemaster"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    Can I insert a blank page if the lot finishes on an odd page?


    Thanks again,


    Dave Gardiner





    ---------------------------------------------------------------------
    To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org