4.2 latexmlpost Customization

§ 4.2.1 XSLT

LaTeXML provides stylesheets for transforming its XML format to XHTML and HTML. These stylesheets are modular with components corresponding to the schema modules. Probably the best strategy for customizing the transform involves making a copy of the standard base stylesheets, LaTeXML-xhtml.xsl, LaTeXML-html.xsl and LaTeXML-html5.xsl, found at installationdir/LaTeXML/style/ — they’re short, consisting mainly of an xsl:include and setting appropriate parameters and output method; thus modifying the parameters and and adding your own rules, or including your own modules should be relatively easy.

Naturally, this requires a familiarity with LaTeXML’s schema (see D), as well as XSLT and XHTML. See the other stylesheet modules in the same directory as the base stylesheet for guidance. Generally the strategy is to use various parameters to switch between common behaviors and to use templates with modes that can be overridden in the less common cases.

Conversion to formats other than XHTML are, of course, possible, as well, but are neither supplied nor covered here. How complex the transformation will be depends on the extent that the LaTeXML schema can be mapped to the desired one, and to what extent LaTeXML has lost or hidden information represented in the original document. Again, familiarity with the schema is needed, and the provided XHTML stylesheets may suggest an approach.

NOTE: I’m trying to make stylesheets easily customizable. However, this is getting tricky.

  • You can import stylesheets which allows the templates to be overridden.

  • You can call the overridden stylesheet using apply-imports

  • You can not call apply-imports to call an overridden named template! (although you seemingly can override them?)

  • You can refer to xslt modules using URN’s, provided you have loaded the LaTeXML.catalog:

    <xsl:import href=”urn:x-LaTeXML:XSLT:LaTeXML-all-xhtml.xsl”/>