Table of Contents
DocBook does not have elements to describe mathematics. DocBook does provide two container elements for mathematics: equation
to format the math as a block (with or without a title), and inlinequation
to include math within a paragraph or other inline context. You have several alternatives for what you put in the container element:
Plain text for simple math.
Capture a representation of the mathematics as a bitmap image.
Model the mathematics with Scalable Vector Graphics (SVG). This solution is only for output formats that can handle SVG.
Model the mathematics in TeX if a downstream process can handle TeX.
Model the mathematics in MathML if a downstream processor can handle MathML.
Some mathematics can be expressed as straight text, using characters from the keyboard and special characters entered as entities. You might think you could put the text in an inlineequation
element, but its content model does not permit bare text.
Starting with version 4.5 of the DocBook XML DTD, you can use a mathphrase
element inside an equation
or inlineequation
element for plain text math. A mathphrase
can contain text, superscript
, subscript
, and emphasis
, which is sufficient for simple math expressions. For example:
<inlineequation> <mathphrase>E = mc<superscript>2</superscript></mathphrase> </inlineequation>
In HTML output, this is output inside a span class="mathphrase"
container, to which you can assign a CSS style to format it in italics, for example.
In print output, the default behavior does not add any styling to mathphrase
. If you want it in italics, for example, you could add a customization like the following:
<xsl:template match="mathphrase"> <xsl:call-template name="inline.italicseq"/> </xsl:template>
If you are using DocBook 4.4 or earlier, the only solution seems to be to use phrase
with a role="math"
attribute for inline instances. The stylesheets do not apply any special formatting to phrase
by default, so you would have to create a stylesheet customization if you want special formatting. The following example makes the math italic:
<xsl:template match="phrase[@role = 'math']"> <xsl:call-template name="inline.italicseq"/> </xsl:template>
The math you can display this way is limited to a linear sequence of text and symbols, with superscript
and subscript
as the only modifiers.
DocBook XSL: The Complete Guide - 4th Edition | PDF version available | Copyright © 2002-2007 Sagehill Enterprises |