Search:  
Gentoo Wiki

HOWTO_Convert_LaTeX_to_HTML_with_MathML

Contents

Introduction

If you're a graduate student or professor working in your research papers, you'd most likely use LaTeX. LaTeX is awesome especially in typing mathematical formulas. Most likely, the papers you're making will be put into a postscript (PS) or a PDF file for publications. Sometimes, you'd prefer to have it converted directly to HTML for direct viewing through your webpage. There was a program to do this, called latex2html, which could do a decent job. However, latex2html always converts mathematical formulas or symbols into pictures, to either PNG or GIF. This means that if you have tons of mathematical formulas, you'd end up with hundreds or sometimes thousands of tiny PNG/GIF files, which is really bad for both user and server. In addition, the PNG or GIF files are usually of very low quality, full of jagged edges.

Converting mathematical formulas or symbols to graphics was unavoidable in yester years, where we didn't have adequate ability to convert to web usuable symbols. However, in recent year, W3 has developed MathML to address this issue. We certainly would like to incorporate this new standard for our purposes.

Before we do anything, I'd suggest you to do "emerge --sync" to obtain the latest greatest package from the portage repository.

Installing LaTeX

If you have already installed LaTeX, you can safely skip this section.

To install LaTeX, invoke the following command:

emerge -av tetex

Installing TeX4ht

The new TeX to HTML converter is called TeX4ht (The old one was latex2html). To install the new one, invoke:

emerge -av tex4ht

Converting TeX to HTML

The last step is of course to convert your TeX paper into an HTML file. To do that, type:

mzlatex my_tex_file "xhtml,mathml-"

You can omit the .tex extension if you like. The newly created file is called my_tex_file.xml. You can copy that along with its css file (my_tex_file.css). The result is amazing.

GUI-based Editor for LaTeX (optional)

If you want to have GUI-based LaTeX editor, you can emerge kile, a KDE-based program:

emerge -av kile

Certainly, you can configure tex4ht inside kile so that you have all-integrated editing environment for your disposal. To do this:

  1. Start kile (usually it's at /usr/bin/kile; you may want to put it into a shortcut).
  2. Then, choose: Settings>Configure Kile>Build>New Tool. Type in "TeX4ht". Click Next button, then Finish button.
  3. At the command text field, type in: mzlatex
  4. At the Options text field, type in: '%source' 'xhtml,mathml-' (with all quotes intact and there is a space between the quoted options)
  5. Click the OK button.

Now, you're ready to use TeX4ht inside Kile. Click Build menu, then Other, then you'll find TeX4ht. If you want to just compile to PS or PDF, you can choose other tools like DVItoPS or DVItoPS in Build menu.

See also

Retrieved from "http://www.gentoo-wiki.info/LaTeX_to_HTML"

Last modified: Sat, 23 Aug 2008 13:27:00 +0000 Hits: 14,774