This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] Hanging Indent


On Fri, Oct 03, 2003 at 05:18:38PM +0200, Wilfred Springer wrote:
> Hi all,
> 
> I'm looking for a way to customize the docbook-xsl stylesheets in order
> to have something like this:
> 
> 1.    Introduction
>       xxx xxxx x xxxxx xxxxx xxxxxxx
>       xxxxx xxxxxx xxxxx xxx xxxxxxx
>       xxxxxx x xxxxx x x xxxxx x xxx
>       xxx xxxx x xxxxx xxxxx xxxxxxx
>       xxxxx xxxxxx xxxxx xxx xxxxxxx
>       xxxxxx x xxxxx x x xxxxx x xxx
> 
> Instead of this:
> 
>       2. Introduction
>       xxx xxxx x xxxxx xxxxx xxxxxxx
>       xxxxx xxxxxx xxxxx xxx xxxxxxx
>       xxxxxx x xxxxx x x xxxxx x xxx
>       xxx xxxx x xxxxx xxxxx xxxxxxx
>       xxxxx xxxxxx xxxxx xxx xxxxxxx
>       xxxxxx x xxxxx x x xxxxx x xxx
> 
> So I want my section numbers to be left-aligned with the page margins,
> and the section title to be left-aligned with the body margins.

You need to use a fo:list-block to get the alignment
you want.  Here is a customization that accomplishes that:

<?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'>

<xsl:import href="../docbook-xsl-1.62.4/fo/docbook.xsl"/>

<xsl:param name="title.margin.left" select="'-0.5in'"/>
<xsl:param name="section.autolabel">1</xsl:param>

<xsl:template match="section|sect1|sect2|sect3|sect4|sect5"
              mode="object.title.markup">
  <fo:list-block provisional-label-separation="0.2em"
                 provisional-distance-between-starts="0.5in"
                 margin-left="0.0in"
                 xsl:use-attribute-sets="section.title.properties"
                 >
    <fo:list-item>
      <fo:list-item-label end-indent="label-end()" text-align="start">
        <fo:block>
          <xsl:apply-templates select="." mode="label.markup"/>
          <xsl:text>.</xsl:text>
        </fo:block>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
        <fo:block>
          <xsl:apply-templates select="." mode="title.markup"/>
        </fo:block>
      </fo:list-item-body>
    </fo:list-item>
  </fo:list-block>
</xsl:template>

</xsl:stylesheet>

The object.title.markup mode is used to generate
the text for a title.  This template customizes
that mode only for section titles. It outputs a
fo:list-block, putting the label (obtained
with mode="label.markup") in the list-item-label
and the title (obtained with mode="title.markup")
in the list-item-body.  

This example uses title.margin.left -0.5in to
set the overall body indent.  The same distance
is used to set the list-block's
provisional-distance-between-starts="0.5in"
so the title part lines up with the body text.

The template has to manually insert the trailing period
after the label because this template is not using the
gentext template that mode="object.title.markup" normally
uses, which has the trailing period. 

Bob Stayton                                 400 Encinal Street
Publications Architect                      Santa Cruz, CA  95060
Technical Publications                      voice: (831) 427-7796
The SCO Group                               fax:   (831) 429-1887
                                            email: bobs@sco.com

To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]