13. Including TeX and LaTeX math

You can include mathematical formulae written in TeX and LaTeX in your document. Here is an example:

There are some limitations:

13.1. Preparing a formula with LaTeX

To use a LaTeX displayed formula, the formula must reside in a separate file, and you must follow a specific structure. Here is the LaTeX source file for the example in Section 13, “Including TeX and LaTeX math”.

% lamath.tex: Sample of LaTeX math for inclusion in DocBook
%
\documentclass[leqno]{article}
\pagestyle{empty}
\setlength{\textwidth}{6in}
\begin{document}
\setcounter{equation}{13}
$$\int \tanh^{-1}{x\over a}dx = x \tanh^{-1}{x\over a}+{a\over 2}\log(a^2-x^2),\qquad \left(\left| x\over a \right| < 1\right)$$
\end{document}

• The option [leqno] instructs LaTeX to place equation numbers on the left side.

• The conversion process selects everything on the page and puts it into a rectangular box. Hence, a page number would force the box to be page-sized. The \pagestyle{empty} command suppresses page numbering.

• The line \setlength{\textwidth}{6in sets the width of the text column to six inches, which matches the text column width in the PDF output from DocBook.

• Use a line \setcounter{equation}{N} to set the equation number to one less than the desired equation number. A value of 13 here will number the equation as (14).

• Place the equation in a $$…$$ environment so that the equation will be numbered.

The math itself is expressed using the usual LaTeX conventions.