Next / Previous / Contents / NM Tech homepage

11.5.10. xref: Page cross-reference format

By default, a page number citation in an xref element is shown in square brackets, e.g., “[12]”. We'd prefer to format them as “(p. 12)” to avoid confusion with the many technical uses of square brackets.

This customization is a little tricky because it involves generated text, that is, text that may depend on the language of the document. Fortunately, on page 244 of Stayton there is an example of exactly this customization. Page 108 of Stayton has a good general introduction to generated text. You might be amused to learn that “l10n” stands for “localization”, and “i18n” stands for “internationalization.” The “%p” in the text attribute of the l:template element is replaced by the actual page number in the rendered document.

zdp_fo.xsl
<!--xref-->
<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="xref">
      <l:template name="page.citation" text=" (p. %p)"/>
    </l:context>
  </l:l10n>
</l:i18n>