I managed to use TeX4ht via the htlatex
command on MiKTeX 2.9 to successfully convert a LaTeX document into an HTML document. The TeX file is a fairly simple test document with an integral in display format. However, I'm using this method as an indirect means to ultimately convert LaTeX into Word with Office MathML (OMML) math. The idea is to convert the TEX file into HTML, and then to simply open the HTML in Word 2010 and save it as DOCX.
Unfortunately, I can't seem to manage to do the entire conversion of LaTeX/TEX into MathML/HTML into Office MathML/DOCX properly. I do manage to get a nice HTML, but that's where I'm stuck.
Here's what I tried. Without options, htlatex
generates a picture in PNG format rather than MathML embedded in the HTML file. Word keeps the picture and no OMML is created.
htlatex
with the option "html,mathml" creates an HTML file with MathML, without a bitmap figure, but Word 2010 cannot read it properly, and the resulting formulas look crudely changed into text with greek letters and in-line symbols.
The option "xhtml,mathml" also gives problems, something along the lines of "DTD prohibited", when opening in Word the HTML file. Tried "xhtml,oofice,mathml" with similar luck.
I wonder if I should use mk4h mzlatex
instead of htlatex
. I haven't tested this alternative because mk4h
on Windows seems to require a Perl interpreter, and it seems pretty much equivalent to htlatex
with the option "xhtml,mozilla" anyway, as indicated in https://stuff.mit.edu/afs/athena/system/i386_deb50/os-ubuntu-9.04/usr/share/doc/tex4ht/html/. htlatex
doesn't require Perl.
DETAILS
Installed MiKTeX 2.9 with both
miktex-tex4ht-bin-2.9
andmiktex-tex4ht-base-2.9
installed with the package manager in administrator mode, on Windows 7.Created a
test.tex
file inE:\downloads
, as follows:\documentclass{report} \begin{document} Hello there. This is a test of $x_i^2=3$, where $$\int_0^\infty f(x) = 1.$$ \end{document}
Converted the TeX file into an HTML file with the following MS DOS commands. It is important to note that as htlatex accepts filenames but not pathnames, it is important to set the current directory to where the tex file resides. If a pathname were given for the test file, e.g., e:\downloads\test.tex, the error "undefined command sequence" would be produced.
e: cd Downloads "C:\Program Files (x86)\MiKTeX 2.9\scripts\tex4ht\htlatex.bat" test.tex
The conversion is successful, but the integral formula appears as a bitmap file, instead of being embedded as MathML.
Tried the following instead, which does generate the Math ML code instead of the image, but Word 2010 cannot recognize it properly and convert it into Office Math ML:
"C:\Program Files (x86)\MiKTeX 2.9\scripts\tex4ht\htlatex" test.tex "html,mathml"