Displaying text items side by side with a hanging indent is a common format that has many applications. Here are some example design ideas:
Display a section number next to an indented section title.
Display a section title next to the indented body text of a section.
Display an admonition icon next to the indented text of the admonition in a note
or caution
, for example.
Display a caption next to an figure.
All of these designs can be achieved using the XSL-FO fo:list-block
element. It formats like a two-column table. One example of its current use is for variablelist
, where it displays each term
element in a varlistentry
next to its listitem
body content. The same kind of side-by-side formatting can be done for a single pair rather than a sequence of pairs. The only restriction is that there be only two items side-by-side. Any more than that and you will need to use a table.
The following is an example customization that puts a section number at the left margin next to its indented section title.
Example 13.15. Format section titles with fo:list-block
<xsl:param name="body.start.indent">30mm</xsl:param><xsl:template name="section.heading">
<xsl:param name="level" select="1"/> <xsl:param name="marker" select="1"/> <xsl:param name="title"/> <xsl:param name="marker.title"/> <xsl:variable name="title.block">
<fo:list-block start-indent="0mm" provisional-distance-between-starts="{$body.start.indent}"
provisional-label-separation="5mm"> <fo:list-item>
<fo:list-item-label end-indent="label-end()" text-align="start">
<fo:block> <xsl:apply-templates select="parent::*" mode="label.markup"/>
</fo:block> </fo:list-item-label> <fo:list-item-body start-indent="body-start()" text-align="start">
<fo:block> <xsl:apply-templates select="parent::*" mode="title.markup"/>
</fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block> </xsl:variable> <fo:block xsl:use-attribute-sets="section.title.properties"> <xsl:if test="$marker != 0"> <fo:marker marker-class-name="section.head.marker"> <xsl:copy-of select="$marker.title"/> </fo:marker> </xsl:if> <xsl:choose> <xsl:when test="$level=1"> <fo:block xsl:use-attribute-sets="section.title.level1.properties"> <xsl:copy-of select="$title.block"/>
</fo:block> </xsl:when> ... </xsl:choose> </fo:block> </xsl:template>
Sets a | |
Customize the template named | |
Define a variable named | |
The
| |
This list block contains a single | |
The | |
The content of the left side is generated by processing the element in | |
The | |
The content of the right side is generated by processing the element in | |
Replace the use of |
Any number of variations can be used. For example, if you use text-align="end"
on the fo:list-item-label
, then the section number will be right-aligned in its space, separated from the left-aligned title by the provisional-label-separation
distance. Other elements can be formatted using similar techniques.
DocBook XSL: The Complete Guide - 4th Edition | PDF version available | Copyright © 2002-2007 Sagehill Enterprises |