LateXSL
setup
modes of operation
For LateXSL to work, the transformation language XSLT must be available.
The simplest way to get XSLT is for the reader to use a modern Web browser, many of which have XSLT built-in.
However, if your Web server supports XSLT, the processing can be done on the server side. The advantage of this approach is that your reader could use an older browser to view the documents. (However, the advantage isn’t so great: most older browsers that don’t support XSLT also don’t support the requisite CSS, and so will make a mess of it anyway.)
Another way to use LateXSL is to pre-process the input XML files, and only place the resulting HTML files on the Web site. This requires the minimum technology of the reader and the Web server, but takes an extra step on the part of the author, each time a change is made. See below.
procedure
install the LateXSL software
Place the contents of the goods/ directory somewhere that your reader can access it.
You could put it in the same directory with your input document, for example. The package files must only remain together.
-
make a proper XHTML input file
Sloppy old HTML will not do.
See the example XML files. If you don’t know what XHTML is, maybe you should read up on it. (It’s not hard, and only slightly different from HTML.)
set your document up for LateXSL
In your input XHTML file, just after the line
<?xml version="1.0" encoding="UTF-8"?>
put a line like<?xml-stylesheet href="../goods/late.xsl" type="text/xsl"?>
where thehref
gives the path to the LateXSL package document late.xsl, relative to the input file.Then tell the browser how to display the math in the HTML with a line like
<link rel="stylesheet" href="../goods/late.css" type="text/css"/>
in thehead
block of your XHTML file.This will cause LateXSL to scan your input files for elements enclosed in
<span class="latex">...</span>
for in-line LaTeX formulas, and<div class="latex">...</div>
for LaTeX display-style formulas. It will also treat paragraphs enclosed in<p class="latex">...</p>
as LaTeX, switching to math mode when it finds a$...$
pair.view your document
You need a full-featured, modern browser.
As of this writing,
- Microsoft Internet Explorer 7
- Firefox 2.+
work well with LateXSL.
Microsoft Internet Explorer 6 will not suffice for direct reading, mostly because its CSS is inadequate to the task.
But
- Microsoft Internet Explorer 7
- Firefox 2.+
- Opera 10.+
- Safari 3.+
all have the requisite CSS.
However, well into writing the code, I found I needed a standard feature of XSL, the
document()
function, that is strangely broken in Opera 10.24 and Safari 3.x. I can and have made LateXSL work without it, but at an awful cost of speed and bloat. I have judged that I would prefer to wait for the manufacturers of these two browsers to fix their bugs, than to waste my time working around them. Opera and Apple have been informed of the problems.
other helpful software
Amaya is useful for checking for proper XHTML syntax.
On Linux and Unix-based systems, there are several stand-alone XSLT processors, which are really useful for debugging. See the Makefile for examples of
- xsltproc
- xalan
- saxon
xsltproc: to validate files without downloading from the network, local copies must be installed on the system. These are typically in /etc/xml, listed in the file catalog. It may be necessary to install special packages to get them to work.
building HTML files
The Makefile is provided to show how one might do XSLT pre-processing. It isn’t necessary for the use of the LateXSL software. As it is, it is useful only on Unix-like systems.
If you type
it will build the example files from the examples/ directory and put the resulting HTML files in the html/ directory.
This pre-processing is really useful for debugging, but also, you might want to pre-process your documents to deliver simple HTML to your readers. You could do that by modifying the Makefile.