Lately I have experimented a lot with Math on the web and maybe some of my conclusions might be helpful to you.
At this point I actually thing that going from LaTeX to HTML is a philosophically wrong way of doing things (I am semi-familiar with most tools for converting LeTeX to HTML).
In liue of my previous conclusion I thing that one should start typing a document from the very beginning with idea that it should display nicely on the web and print nicely as LaTeX. My approach was to adopt txt2tags. However txt2tags has as its main goal to use light mark up to produce 10 different outputs. The price to pay is that outputs are not perfect in any of 10 outputs formats but something that you can work with. My approach is to use txt2tags with idea that end output will be LaTeX or XHTML. Getting reasonably good LaTeX output including formula is possible by including peaces of LaTeX code into t2t ASCII file in tag mode. For example mwe.t2t
mwe.t2t
Predrag Punosevac
Example: Failure of unique prime factorization in $\mathbb{Z}[\sqrt{-5}\hspace{0.1 cm}]$
'''
\begin{equation*}
6 = (1 + \sqrt{-5})\cdot (1 + \sqrt{-5}) = 2 \cdot 3
\end{equation*}
'''
but must be processed with pdflatex!
Processing such file with
txt2tags -t tex mwe.t2t
pdflatex mwe.tex
pdflatex.mwe.tex
will produce "perfect" LaTeX code. But what about XHTML? Well the first thing that we have to investigate is how to properly display mathematics on the web. The answer is MathJex which uses MathML as a backend! MathJex can use various syntax as input to produce mathematics but in particular it can use LaTeX native syntax. That mean that above test file processed as
txt2tags -t xhtml mwe.t2t
is almost what you need. How come? Namely MathJax needs not to be installed on your local machine. You just need to to append mwe.xhtml file with the following few lines of code
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'],
['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorM
ML">
</script>
just after the last meta
tag and fonts for displaying Math on the web will be uploaded from the MathJex server. The page will require a split of a second longer to load but no big deal. It will be correctly displayed on any browser supporting evil JavaScript. Put the above code into mathjax.patch file. The dirty work will be done by sed load file (r-command)
$ more Makefile
SHELL = /bin/sh
.SUFFIXES : .t2t .tex .pdf .html
FILE = lesson_plans
SRC = ${FILE}.t2t
TXT2TAGS = /usr/local/bin/txt2tags
PDFLATEX = /usr/local/bin/pdflatex
TEX = ${SRC:.t2t=.tex}
HTML = ${SRC:.t2t=.html}
XHTML = ${SRC:.t2t=.xhtml}
.xhtml.t2t :
${TXT2TAGS} -t xhtml ${FILE}.t2t
html : ${SRC}
${TXT2TAGS} -t xhtml ${FILE}.t2t
mv ${XHTML} ${HTML}
sed '/meta/r mathjax.patch' ${HTML} > aux
mv aux ${HTML}
${TEX}: ${SRC}
${TXT2TAGS} -t tex ${FILE}.t2t
pdf: ${TEX}
${PDFLATEX} ${TEX}
${PDFLATEX} ${TEX}
clean-html :
/bin/rm -f *.html *.xhtml
clean-tex :
/bin/rm -f *.tex
clean :
/bin/rm -f *.log *.aux *.bbl *.blg *.bm *.toc *.out *.bak
clean-ps : clean
/bin/rm -f *.ps
clean-all : clean-tex clean-html clean
/bin/rm -f *.pdf
Remark I have clean-ps target because I usually use tex->dvi->ps->pdf routine and my .exrc file for nvi editor has
map ^X :w^M:!make pdf clean-ps %^M
So I can do everything just from inside nvi with CTRL+x command.
Enjoy!!!