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:
Marking up equations correctly
Mark your equations with aroleattribute with the valuetex(see examples in Inserting inline).Using the parameter
tex.math.in.alt
Set the parameter tolatex. Add it to a customization file or pass it on the command line to your XSLT processor.Generate your (X)HTML files.
Run the transformation. This creates the filetex-math-equations.texcontaining 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]Generating the DVI file
Compile the filetex-math-equations.texusing the commandlatex. This produces a DVI file.
latex tex-math-equations.tex Converting to PNG
Download from sourceforge.net the programdvi2bitmap, compile it and run it as follows:
dvi2bitmap tex-math-equations.dvi Moving the PNG files
If necessary, move the generated PNG files into the directory containing your (X)HTML files.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top