Customizing inline text

Inline elements such as emphasis can be customized by replacing their templates in a customization layer. See the section “Replacing templates” for a description of the general method. The templates to be customized can be found in fo/inline.xsl for FO output.

Many of the templates for inline elements call one of the following named templates to change font. These template names are also used in the HTML stylesheets.

<xsl:call-template name="inline.charseq"/>Format with normal font.
<xsl:call-template name="inline.boldseq"/>Format with boldface.
<xsl:call-template name="inline.italicseq"/>Format with italics.
<xsl:call-template name="inline.monoseq"/>Format with monospace font.
<xsl:call-template name="inline.italicmonoseq"/>Format with italic monospace font.
<xsl:call-template name="inline.boldmonoseq"/>Format with bold monospace font.
<xsl:call-template name="inline.superscriptseq"/>Format with superscript.
<xsl:call-template name="inline.subscriptseq"/>Format with subscript.

Customizing inline elements that use these templates may mean just calling a different template. For example, this customization changes the font for the filename element from the default monospace to italic:

<xsl:template match="filename">
  <xsl:call-template name="inline.italicseq"/>
</xsl:template>

You can also add templates with more specific match attributes to further customize elements. For example, the filename element can also be used for directory names. You might use the class attribute to distinguish directory names, and then add a custom template to format them in boldface:

<xsl:template  match="filename[@class='directory']">
  <xsl:call-template  name="inline.boldseq"/>
</xsl:template>

The @class='directory' predicate means this template will only be considered for use on filename elements that have a class="directory" attribute. Its match attribute is more specific than the regular filename template, so it has precedence when that role value is used.

If you want to select a font family that is different from the body font, then you need to customize the template a bit further. See the section “Line annotations” for an example of customizing the font used for the lineannotation element.

Subscripts and superscripts

The DocBook XSL stylesheets provide separate attribute-sets for subscripts and superscripts. Some designers are quite picky about how those should be formatted, so these attribute-sets let you fine tune their styles.

Use the subscript.properties attribute-set to style subscripts, and the superscript.properties attribute-set to style superscripts. The default attribute-sets just reduce the font-size to 75%. You can adjust the font size, or change other font properties as in the example below. However, the shift in vertical position of sub- and superscripts is currently not handled by these attribute-sets. That's because the current FOP does not support the preferred baseline-shift property, so a different property must be used for that processor.

<xsl:attribute-set name="superscript.properties">
  <xsl:attribute name="font-size">60%</xsl:attribute>
  <xsl:attribute name="font-family">serif</xsl:attribute>
</xsl:attribute-set>