# Writing LaTeX Mathematical Equations

## Presentation

DocBook doesn't define elements for writing mathematical equations. Only few elements exist that tell how equation should be displayed (inlined, block):

- `inlineequation` tells that the equation is inlined,

- `informalequation` tells that the equation is displayed as a block, without a title.

- `equation` tells that the equation is displayed as a block, with or without a title.

These tags include a graphic (`graphic` or `mediaobject`) or an alternative text equation, as shown by the example.

### Equation taken from TDG

    <equation><title>Last Theorem of Fermat</title>
      <alt>x^n + y^n &ne; z^n &forall; n &ne; 2</alt>
      <graphic fileref="figures/fermat"></graphic>
    </equation>

## Implementation choice

The principle is to use only the `alt` element. If initially `alt` contains actually the text to print, it is chosen to use this element to embed LaTeX mathematical equations. This choice has the following advantages:

- The translation done by dblatex is really easy, since the equation is already written in LaTeX.

- LaTeX is one of the best word processor to render mathematical formulas.

- One doesn't need to write the equations in MathML.

- This method isn't specific to this tool (see the following section).

## Mathematical Delimiters

The dblatex implementation is as light as possible. This is why it is up to the writer to properly use the mathematical delimiters ($, \(, \), \[, \]). By this way the writer fully controls how he writes equations.

By default `dblatex` checks that consistent mathematical delimiters or environment are used in `alt` and it inserts the default math mode delimiters if dblatex thinks they are missing, but you can ask dblatex to write directly the `alt` content without any action. To do this, use the `texmath` Processing Instruction with `delimiters` set to 'user'.

For example, eq-with-texmath-pi has user specific delimiters:

### Equation with user delimiters

In the XML source this equation uses a specific `align*` environment and the `texmath` PI to let the equation as is:

## Compatibility

This implementation is not contradictory nor specific. In particular, the DBTeXMath proposal to extend the DSSSL stylesheets used by jade follows the same approach, and is integrated in the Norman Walsh XSL stylesheets.

## Examples

The following examples show how to write the equations.

### Inlined Equation

### Equation in a block

### Equation in a float

### Equation without a title