This post is about my first attempt at using the lwarp package to compile LaTeX documents into accessible html, using MathJax to render the mathematics. I picked lwarp because it seems to be under active development, and it has a very comprehensive (over 1000 pages) manual.

This is the result for some lecture notes by one of my colleagues. They don’t use any fancy packages (just the ams packages, hyperref, color, graphicx, and enumerate) but they do have a couple of images.

I’d say the results are OK but not perfect (though I haven’t spent much time improving them). There are some annoying imperfections in the html output (mentioned later) and it is definitely not just a matter of typing lwarp myfile.tex - you need to make changes to your tex file to get things working.

Using lwarp

Here is the manual. The part about converting existing tex files is section 6, p.91. In short, what you need to do is:

  1. Install lwarp on your system (it’s in texlive-latex-recommended in the Debian repos, so linux users may already have it).
  2. Copy the \usepackage[...]{lwarp} part of the example file to the top of your tex file, before any other usepackages. Uncomment the option relating to MathJax. (The default is to produce svg graphics with latex commands as alt text, but I didn’t find it worked well for me).
  3. As it stands, MathJax won’t see any macros you have defined in the preamble. If you have \newcommand{\rr}{\mathbb{R}} in the preamble, for example, you’ll just get an error in the MathJax output wherever you use $\rr$. One way round this is to add $\renewcommand{\rr}{\mathbb{R}}$ to the top of your tex file so that MathJax can see it.
  4. Get rid of any [scale] commands in your includegraphics and replace with a sensible absolute size.
  5. Get rid of any double primes written like this: y'' (the primes are rendered as a black triangle). The only thing I found that worked correctly was y^{\prime\prime}, and I was too lazy to fix them all. In fact I was too lazy to fix more than one.
  6. Now compile with pdflatex or latexmk, then run lwarpmk html. You will get myfile.html and some css files which need to be uploaded wherever you want to display the files.

-- and --- in the LaTeX source are rendered as weird symbols in the html output. This might be an issue with fonts or with the way lwarp extracts text.