Fwd: Fwd: Header and footer alignment for center cell
Ron Catterall <[email protected]> Mon, 19 Jul 2021 23:38:31 +0100
| Newsgroups | gmane.text.docbook.apps |
|---|---|
| Message-ID | <[email protected]> |
Hi Kevin
A long time ago I set this up in my xsl and it is still working. Don't
know if it is of any use.
<!--
======================================================================== -->
<!-- set relative space in header for left, center and right cells -->
<xsl:param name="header.column.widths" select="'1 10 1'">
</xsl:param> <!-- book title on odd, chapter title on even -->
<!--
======================================================================== -->
<!-- rule below header -->
<xsl:param name="header.rule" select="0" > </xsl:param>
<!--
======================================================================== -->
<!-- define the rule below the header -->
<xsl:template name="head.sep.rule">
<xsl:param name="pageclass"/>
<xsl:param name="sequence"/>
<xsl:param name="gentext-key"/>
<xsl:if test="$header.rule != 0">
<xsl:attribute name="border-bottom-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-bottom-style">solid</xsl:attribute>
<xsl:attribute name="border-bottom-color">black</xsl:attribute>
</xsl:if>
</xsl:template> <!-- END name="head.sep.rule" -->
<!--
======================================================================== -->
<xsl:attribute-set name="header.content.properties">
<xsl:attribute name="font-size">11pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
<!--
======================================================================== -->
<!-- set header content style -->
<xsl:template name="header.content">
<xsl:param name="pageclass" select="''"> </xsl:param>
<xsl:param name="sequence" select="''"> </xsl:param>
<xsl:param name="position" select="''"> </xsl:param>
<xsl:param name="gentext-key" select="''"> </xsl:param>
<!-- <xsl:variable name="sectname">
<fo:retrieve-marker retrieve-class-name="." />
</xsl:variable> -->
<xsl:variable name="candidate">
<!-- sequence can be odd, even, first, blank -->
<!-- position can be left, center, right -->
<xsl:choose>
<xsl:when test="$sequence = 'odd' and $position = 'left'">
</xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'odd' and
$position = 'center'">
<fo:retrieve-marker
retrieve-class-name="section.head.marker"
retrieve-position="first-including-carryover"
retrieve-boundary="page-sequence"/>
<xsl:value-of
select="ancestor-or-self::d:chapter/d:info/d:title"/> <!-- OK -->
</xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'odd' and
$position = 'right'"> </xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position = 'left'"> </xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position = 'center'">
<xsl:value-of
select="ancestor-or-self::d:book/d:info/d:title"/> <!-- OK -->
</xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position = 'right'"> </xsl:when>
<xsl:when test="$sequence = 'first' and $position = 'left'">
</xsl:when>
<xsl:when test="$sequence = 'first' and $position = 'right'">
</xsl:when>
<xsl:when test="$sequence = 'first' and $position = 'center'">
</xsl:when>
<xsl:when test="$sequence = 'blank' and $position = 'left'">
</xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'blank' and
$position = 'center'">
<xsl:text>Blank Page</xsl:text>
</xsl:when>
<xsl:when test="$sequence = 'blank' and $position = 'right'">
</xsl:when>
<xsl:when test="$double.sided = 0 and $sequence = 'blank'">
</xsl:when>
<xsl:when test="$double.sided = 0 and $position = 'left'">
</xsl:when>
<xsl:when test="$double.sided = 0 and $position = 'center'">
<xsl:value-of
select="ancestor-or-self::d:book/d:info/d:title"> </xsl:value-of> <!--
book or article ??? *********** -->
</xsl:when>
<xsl:when test="$double.sided = 0 and $position = 'right'">
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- Does runtime parameter turn off blank page headers? -->
<xsl:choose>
<xsl:when test="$sequence='blank' and $headers.on.blank.pages=0">
<!-- no output -->
</xsl:when>
<!-- titlepages have no headers -->
<xsl:when test="$pageclass = 'titlepage'">
<!-- no output -->
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$candidate"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template> <!-- END name="header.content" -->
<!--
======================================================================== -->
<!-- set relative space in footer for left, center and right cells -->
<xsl:param name="footer.column.widths" select="'2 1 2'"> </xsl:param>
<!--
======================================================================== -->
<!-- rule above footer -->
<xsl:param name="footer.rule" select="0"> </xsl:param>
<!--
======================================================================== -->
<!-- define the rule above the footer -->
<xsl:template name="foot.sep.rule">
<xsl:param name="pageclass"> </xsl:param>
<xsl:param name="sequence"> </xsl:param>
<xsl:param name="gentext-key"> </xsl:param>
<xsl:if test="$footer.rule != 0">
<xsl:attribute name="border-top-width">0.5pt</xsl:attribute>
<xsl:attribute name="border-top-style">solid</xsl:attribute>
<xsl:attribute name="border-top-color">black</xsl:attribute>
</xsl:if>
</xsl:template> <!-- END name="foot.sep.rule" -->
<!--
======================================================================== -->
<!-- set footer content style -->
<xsl:attribute-set name="footer.content.properties">
<xsl:attribute name="font-size">10pt</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
<!--
======================================================================== -->
<!-- customize the footer content. Original at line 2377 of
fo/pagesetup.xsl -->
<xsl:template name="footer.content">
<xsl:param name="pageclass" select="''"> </xsl:param>
<xsl:param name="sequence" select="''"> </xsl:param>
<xsl:param name="position" select="''"> </xsl:param>
<xsl:param name="gentext-key" select="''"> </xsl:param>
<!--
<fo:block>
<xsl:value-of select="$pageclass"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$sequence"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$position"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$gentext-key"/>
</fo:block>
-->
<fo:block>
<!-- pageclass can be front, body, back -->
<!-- sequence can be odd, even, first, blank -->
<!-- position can be left, center, right -->
<xsl:choose>
<xsl:when test="$pageclass = 'titlepage'">
<!-- nop; no footer on title pages -->
</xsl:when>
<!-- Double Sided Even -->
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position='left'">
<fo:page-number/>
</xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position='center'"> </xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position='right'">
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:firstname"/>
<xsl:value-of select="' '"/>
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:surname"/>
</xsl:when>
<!-- Double Sided Odd or First -->
<xsl:when test="$double.sided != 0 and ($sequence = 'odd' or
$sequence = 'first') and $position='left'">
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:firstname"/>
<xsl:value-of select="' '"/>
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:surname"/>
</xsl:when>
<xsl:when test="$double.sided != 0 and ($sequence = 'odd' or
$sequence = 'first') and $position='center'"> </xsl:when>
<xsl:when test="$double.sided != 0 and ($sequence = 'odd' or
$sequence = 'first') and $position='right'">
<fo:page-number/>
</xsl:when>
<!-- Double Sided Odd -->
<xsl:when test="$double.sided != 0 and $sequence = 'odd' and
$position='left'">
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:firstname">
</xsl:value-of>
<xsl:value-of select="' '"> </xsl:value-of>
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:surname">
</xsl:value-of>
</xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position='center'"> </xsl:when>
<xsl:when test="$double.sided != 0 and $sequence = 'even' and
$position='right'">
<fo:page-number/>
</xsl:when>
<!-- single Sided -->
<xsl:when test="$double.sided = 0">
<xsl:choose>
<xsl:when test="$position='left'">
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:firstname">
</xsl:value-of>
<xsl:value-of select="' '"> </xsl:value-of>
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:surname">
</xsl:value-of>
</xsl:when>
<xsl:when test="$position='center'"> </xsl:when>
<xsl:when test="$position='right'">
<fo:page-number/>
</xsl:when>
<xsl:otherwise>
<!-- nop -->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Blank Pages -->
<xsl:when test="$sequence='blank'">
<xsl:choose>
<!-- Double Sided - No Footers -->
<xsl:when test="$double.sided != 0 and $position = 'left'">
</xsl:when>
<xsl:when test="$double.sided != 0 and $position =
'center'"> </xsl:when>
<xsl:when test="$double.sided != 0 and $position =
'right'"> </xsl:when>
<!-- Single Sided - Footers as usual if this should occur -->
<xsl:when test="$double.sided = 0 and $position='left'">
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:firstname">
</xsl:value-of>
<xsl:value-of select="' '"> </xsl:value-of>
<xsl:value-of
select="ancestor-or-self::d:article/d:info/d:authorgroup/d:author/d:personname/d:surname">
</xsl:value-of>
</xsl:when>
<xsl:when test="$double.sided = 0 and $position='center'">
</xsl:when>
<xsl:when test="$double.sided = 0 and $position='right'">
<fo:page-number/>
</xsl:when>
<xsl:otherwise>
<!-- nop -->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- nop -->
</xsl:otherwise>
</xsl:choose>
</fo:block>
</xsl:template> <!-- END name="footer.content" -->
<!--
======================================================================== -->
>
> *From: *Bob Stayton <[email protected] <mailto:[email protected]>>
> *Subject: **Re: [docbook-apps] Header and footer alignment for center
> cell*
> *Date: *19 July 2021 at 15:33:03 GMT-5
> *To: *Kevin Dunn <[email protected] <mailto:[email protected]>>,
> "[email protected]
> <mailto:[email protected]>"
> <[email protected]
> <mailto:[email protected]>>
>
> Hi Kevin,
>
> If you want your footer content on the outside, then I suggest you not
> put it in the center cell, but instead put it in the left or right
> cell, depending on the page number. That's done in the template named
> "footer.content" that you would customize to define what appears in
> your footer cells. You can also adjust the relative column widths or
> make the center column width zero if you don't use it. The details
> are described here:
>
> http://track.smtpsendemail.com/13771/c?p=eJh80XZhBYY_APu_J9WGEzXdohT2a0VvunE2N93Ownva_qVsJ3LmfSsVvOMvAj8zfEfvQkPGPXdW5VIp8dKfTmDnMK-wmp1Tm1zvDVCZs1lIrPupt_vql8ICytgkwk832J-ghThTTWMzBifLQvTG-3XWMTkyBr6REMf_50HWSNiFLqWSYiWT3DyKGN1yNDTk
>
> Here is what I used in my book for the footers, which put the
> copyright on the inside and page number on the outside. I left the
> conditional clauses for $double.sided = 0 even though I never used
> that setting.
>
> <xsl:param name="footer.column.widths">10 0 1</xsl:param>
>
> <xsl:template name="footer.content">
> <xsl:param name="pageclass" select="''"/>
> <xsl:param name="sequence" select="''"/>
> <xsl:param name="position" select="''"/>
> <xsl:param name="gentext-key" select="''"/>
>
> <fo:block>
>
> <!-- sequence can be odd, even, first, blank -->
> <!-- position can be left, center, right -->
> <xsl:choose>
> <xsl:when test="$sequence='blank'">
> <xsl:choose>
> <xsl:when test="$double.sided != 0 and $position = 'left'">
> <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
> </xsl:when>
> <xsl:when test="$double.sided != 0 and $position = 'right'">
> <xsl:call-template name="footer.copyright"/>
> </xsl:when>
> <xsl:when test="$double.sided = 0 and $position = 'right'">
> <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
> </xsl:when>
> <xsl:when test="$double.sided = 0 and $position = 'left'">
> <xsl:call-template name="footer.copyright"/>
> </xsl:when>
> <xsl:otherwise>
> <!-- nop -->
> </xsl:otherwise>
> </xsl:choose>
> </xsl:when>
>
> <xsl:when test="$pageclass='titlepage'">
> <!-- nop: other titlepage sequences have no footer -->
> </xsl:when>
>
> <xsl:when test="$double.sided != 0 and ($sequence = 'even' or
> $sequence = 'last') and $position='left'">
> <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
> </xsl:when>
>
> <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or
> $sequence = 'first') and $position='right'">
> <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
> </xsl:when>
>
> <xsl:when test="$double.sided != 0 and ($sequence = 'even' or
> $sequence = 'last') and $position='right'">
> <xsl:call-template name="footer.copyright"/>
> </xsl:when>
>
> <xsl:when test="$double.sided != 0 and ($sequence = 'odd' or
> $sequence = 'first') and $position='left'">
> <xsl:call-template name="footer.copyright"/>
> </xsl:when>
>
> <xsl:when test="$double.sided = 0 and $position='right'">
> <fo:inline font-weight="bold"><fo:page-number/></fo:inline>
> </xsl:when>
>
> <xsl:when test="$double.sided = 0 and $position='left'">
> <xsl:call-template name="footer.copyright"/>
> </xsl:when>
>
> <xsl:otherwise>
> <!-- nop -->
> </xsl:otherwise>
> </xsl:choose>
> </fo:block>
> </xsl:template>
>
> <xsl:template name="footer.copyright">
> <fo:inline font-size="6pt">
> <xsl:apply-templates select="/d:book/d:info/copyright[1]"
> mode="titlepage.mode"/>
> </fo:inline>
> </xsl:template>
>
> Let me know if any of this requires further explanation.
>
> Bob Stayton
> [email protected]
> On 7/19/2021 12:39 PM, Kevin Dunn wrote:
>> In double-sided xsl-fo, how can you control text-align for the center
>> cell of the header or footer table (usually chapter or section title)?
>>
>> Using the attribute-set footer.table.properties, I can set
>> text-align, but it doesn't distinguish between recto and verso pages.
>> "center" centers the center cell for both recto and verso pages,
>> which is acceptable. But some books (e.g., DocBook XSL TCG) align
>> "end" on the recto pages and "start" on the verso pages, which I find
>> attractive.
>>
>> I tried customizing footer.table.cell.properties, but that had no affect.
>>
>> Would I have to customize the footer.table template, or can it be
>> done with attribute-sets?
>>
>> Get Outlook for Android <http://track.smtpsendemail.com/13771/c?p=O3KRg0-bEx6j67G2u9McZvuI3z4dDwSNVMYP0aXxS2F-iQ7-7033pT0FBIbI7SY3dmannivZCLOcg2tXQYtmPNXLz4oMusQKdBEh7qlUiMmHCQpYPdC6jZepyN0fZk60>