LaTeXML The Manual

Chapter 4 Customization

The processsing of the LaTeX document, its conversion into XML and ultimately to XHTML or other formats can be customized in various ways, at different stages of processing and in different levels of complexity. Depending on what you are trying to achieve, some approaches may be easier than others: Recall Larry Wall’s adage “There’s more than one way to do it.”

By far, the easiest way to customize the style of the output is by modifying the CSS, see 4.2.2, so that is the recommended way when it applies.

The basic conversion from TeX markup to XML is done by latexml, and is obviously affected by the mapping between the TeX markup and the XML markup. This mapping is defined by macros, primitives and, of course, constructors; The mapping that is in force at any time is determined by the LaTeXML-specific implementations of the TeX packages involved, what we call ‘bindings’. Consequently, you can customize the conversion by modifying the bindings used by latexml.

Likewise, you extend latexml by creating bindings for TeX styles that hadn’t been covered.

Or by defining your own TeX style file along with it’s LaTeXML binding.

In all these cases, you’ll need the same skills: understanding and using text, tokens, boxes and whatsits, as well as macros and macro expansion, primitives and digestion, and finally whatsits and constructors. Understanding TeX helps; reading the LaTeXML bindings in the distribution will give an idea of how we use it. To teach LaTeXML about new macros, to implement bindings for a package not yet covered, or to modify the way TeX control sequences are converted to XML, you will want to look at 4.1. To modify the way that XML is converted to other formats such as HTML, see 4.2.

A particularly powerful strategy when you have control over the source documents is to develop a semantically oriented LaTeX style file, say smacros.sty, and then provide a LaTeXML binding as smacros.sty.ltxml. In the LaTeX version, you may style the terms as you like; in the LaTeXML version, you could control the conversion so as to preserve the semantics in the XML. If LaTeXML’s schema is insufficient, then you would need to extend it with your own representation; although that is beyond the scope of the current manual, see the discussion below in 4.1.4. In such a case, you would also need to extend the XSLT stylesheets, as discussed in 4.2.1.