As touched upon in a comment by the OP, just using the following is enough to introduce a margin on figures that float right or left:
<xsl:attribute-set name="figure.properties">
<xsl:attribute name="margin-left">6pt</xsl:attribute>
<xsl:attribute name="margin-right">6pt</xsl:attribute>
</xsl:attribute-set>
I think my original answer (below) was unnecessarily complicated.
The template named floater
(see http://www.sagehill.net/docbookxsl/SideFloats.html#CustomSideFloat) outputs the fo:float
formatting object. This template takes start.indent
and end.indent
parameters with default values of 0. These default values are unfortunately not changed when the figure
template calls floater
, resulting in the problem that you see.
You only need a small fix in the template matching figure
to make it work (see the comment in the code below). So add the following to your customization layer:
<xsl:template match="figure">
<xsl:variable name="param.placement"
select="substring-after(normalize-space($formal.title.placement),
concat(local-name(.), ' '))"/>
<xsl:variable name="placement">
<xsl:choose>
<xsl:when test="contains($param.placement, ' ')">
<xsl:value-of select="substring-before($param.placement, ' ')"/>
</xsl:when>
<xsl:when test="$param.placement = ''">before</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$param.placement"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="figure">
<xsl:choose>
<xsl:when test="@pgwide = '1'">
<fo:block xsl:use-attribute-sets="pgwide.properties">
<xsl:call-template name="formal.object">
<xsl:with-param name="placement" select="$placement"/>
</xsl:call-template>
</fo:block>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="formal.object">
<xsl:with-param name="placement" select="$placement"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="floatstyle">
<xsl:call-template name="floatstyle"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$floatstyle != ''">
<xsl:call-template name="floater">
<xsl:with-param name="position" select="$floatstyle"/>
<xsl:with-param name="content" select="$figure"/>
<!-- The following two lines added to introduce a 10pt 'margin' for floats (right or left) -->
<xsl:with-param name="start.indent">10pt</xsl:with-param>
<xsl:with-param name="end.indent">10pt</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$figure"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>