XML technologies / DocBook / Generating (X)HTML / Adding mathematical formulas to (X)HTML

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

In DocBook, mathematical formulas use the elements equation, informalequation or inlineequation (see Equations).

If these three elements contain MathML markup, it is passed through during transformation to (X)HTML. Browsers such as Mozilla, Firefox and Opera can render MathML directly. Other browsers require the formula as an image, generated through LaTeX. Proceed as follows:

  1. Marking up equations correctly
    Mark your equations with a role attribute with the value tex (see examples in Inserting inline).

  2. Using the parameter tex.math.in.alt
    Set the parameter to latex. Add it to a customization file or pass it on the command line to your XSLT processor.

  3. Generate your (X)HTML files.
    Run the transformation. This creates the file tex-math-equations.tex containing your equation’s LaTeX code. A DocBook document produces the following content:

\documentclass{article} 
\pagestyle{empty} 
\begin{document} 
\special{dvi2bitmap outputfile eq1.png} 
$$N = N_0 e^{-\lambda t}$$ 
\newpage 
\end{document]

  1. Generating the DVI file
    Compile the file tex-math-equations.tex using the command latex. This produces a DVI file.

latex tex-math-equations.tex 

  1. Converting to PNG
    Download from sourceforge.net the program dvi2bitmap, compile it and run it as follows:

dvi2bitmap tex-math-equations.dvi 

  1. Moving the PNG files
    If necessary, move the generated PNG files into the directory containing your (X)HTML files.

  

back to top