OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] widow/orphan & subsection font size


Hi Tristan,
First, let's be clear about the terminology.  Widows and orphans in
typesetting refer to lines of a single text block, such as a paragraph.  In
XSL-FO, the widow and orphan properties are set to the value of 2 by
default.  If you want to set them to something larger, you can do so in the
'root.properties' attribute-set, but they won't have the effect you are
looking for.

The property you seek is "keep", one of keep-together, keep-with-next, or
keep-with-previous. These apply glue between two adjacent blocks to keep
them together on a page (or column, or line). The DocBook XSL stylesheets
automatically add keep-with-next to each section title to keep it with its
following text (see the 'section.title.properties' attribute-set).  But FOP
hasn't yet implemented it, except for table rows.

The best solution is replace FOP with an XSL-FO processor that handles
keeps, such as XSL Formatter, XEP, or Xml2Pdf.  Then all your keeps
will be automagically working.

But if you must use FOP, then you could try the following customization.  It
works with <section> elements, not with sect1, sect2, etc.  It could be
adapted
to work with them if you use those elements.  It puts the section title and
the element
after the title into a table, with keeps between the two rows.  It seems to
work
in most cases, but in some cases it does not force the title to the next
page,
even though all the properties are set.  I can't explain why it doesn't work
in
those cases.

<xsl:template name="section.content">
  <fo:table table-layout="fixed"
    width="{$page.width} - {$page.margin.inner} - {$page.margin.outer}">
    <fo:table-column column-width="proportional-column-width(1)"/>
    <fo:table-body>
      <fo:table-row keep-with-next.within-column="always">
        <fo:table-cell>

          <xsl:call-template name="section.titlepage"/>

          <xsl:variable name="toc.params">
            <xsl:call-template name="find.path.params">
              <xsl:with-param name="table"
select="normalize-space($generate.toc)"/>
            </xsl:call-template>
          </xsl:variable>

          <xsl:if test="contains($toc.params, 'toc')
                        and (count(ancestor::section)+1) &lt;=
$generate.section.toc.level">
            <xsl:call-template name="section.toc">
              <xsl:with-param name="toc.title.p"
select="contains($toc.params, 'title')"/>
            </xsl:call-template>
           <xsl:call-template name="section.toc.separator"/>
          </xsl:if>
        </fo:table-cell>
      </fo:table-row>

      <fo:table-row keep-with-previous.within-column="always">
        <fo:table-cell>
          <xsl:apply-templates select="title/following-sibling::*[1]"/>
        </fo:table-cell>
      </fo:table-row>
    </fo:table-body>
  </fo:table>

  <xsl:apply-templates select="title/following-sibling::*[not(position() =
1)]"/>
</xsl:template>


Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Tristan Fiedler" <fiedler@cshl.edu>
To: "Docbook-Apps" <docbook-apps@lists.oasis-open.org>
Cc: "Lisa Girard" <lgirard@its.caltech.edu>
Sent: Friday, May 27, 2005 5:20 PM
Subject: [docbook-apps] widow/orphan & subsection font size


> Software : DocBook 4.4CR2, XSL 1.67.2, FOP 0.20.5, and Saxon 6.5.3
>
> I have looked through the online DocBook guide, as well as the DocBook
> XSL book and find essentially nothing on widow / orphan control.
>
> How can I prevent "title" widows / orphans from occurring?  I am
> referring here to <sect2> titles being at the bottom of a page, and the
> first paragraph of text for that section beginning on the next page.
> (I did not see any problems with the <sect1> titles, but this may be
> coinincidence).  I have tried the following with no success :
>
>
> <xsl:attribute-set name="root.properties">
> <xsl:attribute name="widows">4</xsl:attribute>
> <xsl:attribute name="orphans">4</xsl:attribute>
>
> Perhaps a keep-together with directive?  Could someone please give an
> example?  A have seen many report that FOP 0.20.5 only supports keep-*
> within table?  Could someone give an example of using a "blind" table
> to keep the following title together the first paragraph:
>
> <sect2>
> <title>My title</title>
> <para>Sentence 1....Sentence 2.....Sentence 3</para>
>
> Cheers,        Tristan
> ---
> Tristan J. Fiedler
> Cold Spring Harbor Laboratory
>
>
> [My XSL-FO stylesheet customization layer is pasted at the end of this
> email, in case I have inserted something which is preventing section
> title from keeping with the first paragraph of text]
>
> <?xml version='1.0'?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";
> version="1.0">
> <!-- Above fo namespace declaration needed for caption alignment -->
>
> <xsl:import
> href="/Users/fiedler/Celegans_DocBook/software/docbook-xsl-1.67.2/fo/
> docbook.xsl"/>
>
> <xsl:param name="fop.extensions" select="1"></xsl:param>
> <xsl:param name="draft.mode" select="'yes'"></xsl:param>
> <xsl:param name="draft.watermark.image"
> select="'http://docbook.sourceforge.net/release/images/draft.png'"></
> xsl:param>
> <xsl:param name="insert.xref.page.number">no</xsl:param>
>
> <!-- Section Number turned on, per Lincoln's request 16 Feb 2005 -->
> <xsl:param name="section.autolabel" select="1"></xsl:param>
>
> <!-- In order to show the URL in the footnote, ulink.show must be
> nonzero -->
> <xsl:param name="ulink.show" select="0"></xsl:param>
> <xsl:param name="ulink.footnotes" select="0"></xsl:param>
>
> <!-- Remove little square bracket label from the beginning of the
> biblioentry, see http://www.sagehill.net/docbookxsl/CustomBiblio.html
> -->
> <xsl:template name="biblioentry.label"></xsl:template>
>
> <xsl:attribute-set name="xref.properties"> <!-- Colors PDF hyperlinks
> -->
> <xsl:attribute name="color">blue</xsl:attribute>
> </xsl:attribute-set>
>
>
> <!-- Put Title (ie Caption) after formal table : Begin -->
>
> <xsl:param name="formal.title.placement">
> figure before
> example before
> equation before
> table after
> procedure before
> task before
> </xsl:param>
>
> <!-- Put Title (ie Caption) after formal table : End -->
>
> <!-- Put Only Table Title, Not Autonumbering (see XSL common/en.xml:
> Begin -->
>
> <xsl:param name="local.l10n.xml" select="document('')"/>
> <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
> <l:l10n language="en">
> <l:context name="title">
> <l:template name="table" text="%t"/>
> </l:context>
>
>       <!-- other customizations -->
> </l:l10n>
> </l:i18n>
>
> <!-- Put Only Table Title, Not Autonumbering : End -->
>
>
> <!-- Include Editor Address & Email in PDF output: Begin
> <xsl:template match="editor[1]" priority="2" mode="titlepage.mode">
>   This is just inserted text for my template
>
> <xsl:call-template name="gentext.edited.by"/>
>    <xsl:call-template name="gentext.space"/>
>    <xsl:call-template name="person.name.list">
>      <xsl:with-param name="person.list" select="../editor"/>
>    </xsl:call-template>
>    <xsl:if test="affiliation/orgname">
>        <xsl:text>, </xsl:text>
>        <xsl:apply-templates select="affiliation/orgname"
> mode="titlepage.mode"/>
>    </xsl:if>
>    <xsl:if test="affiliation/address">
>        <xsl:text>, </xsl:text>
>        <xsl:apply-templates select="affiliation/address"
> mode="titlepage.mode"/>
>    </xsl:if>
>    <xsl:if test="email|affiliation/address/email">
>        <xsl:text> </xsl:text>
>        <xsl:apply-templates
> select="(email|affiliation/address/email)[1]"/>
>    </xsl:if>
> </xsl:template>
>
>   Include Editor Address & Email in PDF output: End -->
>
> <!-- Turn OFF bolding table titles in PDF output.  Modified from
> params/formal.title.properties.xsl  Begin -->
>
> <xsl:attribute-set name="formal.title.properties"
> use-attribute-sets="normal.para.spacing">
> <xsl:attribute name="font-weight">normal</xsl:attribute>
> <xsl:attribute name="font-size">
> <xsl:value-of select="$body.font.master * 1.0"/>
> <xsl:text>pt</xsl:text>
> </xsl:attribute>
> <xsl:attribute name="hyphenate">false</xsl:attribute>
> <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
> <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
> <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
> </xsl:attribute-set>
>
>   <!-- Turn OFF bold table titles in PDF output.  Modified from
> params/formal.title.properties.xsl  End -->
>
>
> <!--Patch to allow imagedata element to be centered, but caption to be
> left justified, since align attribute does not appear to work on the
> caption element - BEGIN -->
> <!-- Should not be needed in the future; bug report filed at
> sourceforge, per Bob Stayton's request -->
>
> <xsl:template match="caption">
> <fo:block>
> <xsl:attribute name="text-align">
> <xsl:choose>
> <xsl:when test="@align != ''">
> <xsl:value-of select="@align"/>
> </xsl:when>
> <xsl:otherwise>left</xsl:otherwise>
> </xsl:choose>
> </xsl:attribute>
> <xsl:apply-templates/>
> </fo:block>
> </xsl:template>
>
> <!--Patch to allow imagedata element to be centered, but caption to be
> left justified, since align attribute does not appear to work on the
> caption element - END -->
>
> <!-- Removes the left margin "out-dent" for titles.  Default is that
> titles are shifted to the left of the main text. - BEGIN -->
> <xsl:param name="title.margin.left">
> <xsl:choose>
> <xsl:when test="$passivetex.extensions != 0">0pt</xsl:when>
> <xsl:otherwise>0pt</xsl:otherwise>
> </xsl:choose>
> </xsl:param>
> <!-- Removes the left margin "out-dent" for titles.  Default is that
> titles are shifted to the left of the main text. - END -->
>
> <!-- Reduces section title size from default value of 1.8 - BEGIN -->
> <xsl:attribute-set name="section.title.level1.properties">
> <xsl:attribute name="font-size">
> <xsl:value-of select="$body.font.master * 1.2"/>
> <xsl:text>pt</xsl:text>
> </xsl:attribute>
> </xsl:attribute-set>
>
> <xsl:attribute-set name="section.title.level2.properties">
> <xsl:attribute name="font-size">
> <xsl:value-of select="$body.font.master * 1.0"/>
> <xsl:text>pt</xsl:text>
> </xsl:attribute>
> </xsl:attribute-set>
> <!-- Reduces section title size from default value of 1.8 - END -->
>
> <!-- Remove default bibliography title, and just use section title -
> BEGIN -->
> <xsl:template name="bibliography.titlepage">
> </xsl:template>
> <!-- Remove default bibliography title, and just use section title -
> END -->
>
>
>
> <xsl:param name="symbol.font.family" select="'Symbol,
> ZapfDingbats'"></xsl:param>
>
> <!-- Force Special Characters to change to Symbol font
> (http://www.sagehill.net/docbookxsl/SpecialChars.html)  - BEGIN -->
> <!-- Due to an FOP glitch, the font-family line below will only use the
> first font. See threads on DocBook-apps Feb16 2005
>
> Jirka wrote :  Unfotunately you are no luck with FOP because it doesn't
> support font-selection-strategy="character-by-character". XEP and XSL
> Formatter do.
> Bob Stayton wrote :  a list of fonts (e.g. Symbol,ZapfDingbats)  in the
> font-family property don't work in FOP yet. You are going to have to
> specify a single font-family..
>
> usage :       <symbol role="symbolfont">&#x2194;</symbol>  where x2194
> is the "arrowboth" in Symbol font. -->
> <!-- Also note that font-style & font-weight set to normal since the
> PDF output was not properly displacing italics for symbols. -->
> <xsl:template match="symbol[@role = 'symbolfont']">
> <fo:inline font-family="Symbol,ZapfDingbats" font-style="normal"
> font-weight="normal">
> <xsl:apply-templates/>
> <!-- <xsl:call-template name="inline.charseq"/>   -->
> </fo:inline>
> </xsl:template>
> <!-- Force Special Characters to change to Symbol font
> (http://www.sagehill.net/docbookxsl/SpecialChars.html)  - END -->
>
>
> <!-- One or Two Columns - BEGIN -->
> <xsl:param name="column.count.body" select="1"></xsl:param>
> <!-- One or Two Columns - END -->
>
> <!-- Change footnote format to these symbols, see
> http://docbook.sourceforge.net/release/xsl/current/doc/html/
> footnote.number.symbols.html   -->
> <xsl:param name="footnote.number.symbols"
> select="'*&#xa7;&#x2020;&#x2021;*'"></xsl:param>
>
> <!-- To remove the second line indentation from the PDF bibliographic
> entries.  One line modified from fo/biblio.xsl  - BEGIN  -->
> <xsl:template match="bibliomixed">
>    <xsl:param name="label">
>      <xsl:call-template name="biblioentry.label"/>
>    </xsl:param>
>
>    <xsl:variable name="id">
>      <xsl:call-template name="object.id"/>
>    </xsl:variable>
>
>    <xsl:choose>
>      <xsl:when test="string(.) = ''">
>        <xsl:variable name="bib"
> select="document($bibliography.collection,.)"/>
>        <xsl:variable name="entry"
> select="$bib/bibliography/*[@id=$id][1]"/>
>        <xsl:choose>
>          <xsl:when test="$entry">
>   <xsl:choose>
>     <xsl:when test="$bibliography.numbered != 0">
>       <xsl:apply-templates select="$entry">
> <xsl:with-param name="label" select="$label"/>
>       </xsl:apply-templates>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:apply-templates select="$entry"/>
>     </xsl:otherwise>
>   </xsl:choose>
>          </xsl:when>
>          <xsl:otherwise>
>            <xsl:message>
>              <xsl:text>No bibliography entry: </xsl:text>
>              <xsl:value-of select="$id"/>
>              <xsl:text> found in </xsl:text>
>              <xsl:value-of select="$bibliography.collection"/>
>            </xsl:message>
>            <fo:block id="{$id}"
> xsl:use-attribute-sets="normal.para.spacing">
>              <xsl:text>Error: no bibliography entry: </xsl:text>
>              <xsl:value-of select="$id"/>
>              <xsl:text> found in </xsl:text>
>              <xsl:value-of select="$bibliography.collection"/>
>            </fo:block>
>          </xsl:otherwise>
>        </xsl:choose>
>      </xsl:when>
>      <xsl:otherwise>
>        <fo:block id="{$id}" xsl:use-attribute-sets="normal.para.spacing"
>                  start-indent="0.0in" text-indent="0.0in">
> <xsl:copy-of select="$label"/>
>          <xsl:apply-templates mode="bibliomixed.mode"/>
>        </fo:block>
>      </xsl:otherwise>
>    </xsl:choose>
> </xsl:template>
> <!-- To remove the second line indentation from the PDF bibliographic
> entries.  One line modified from fo/biblio.xsl  - END  -->
>
> <!-- Testing widow / orphan control  -->
> <xsl:attribute-set name="root.properties">
> <xsl:attribute name="widows">4</xsl:attribute>
> <xsl:attribute name="orphans">4</xsl:attribute>
>
>
> </xsl:attribute-set>
>
> </xsl:stylesheet>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>
>
>




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]