f2ht is a command line tool for importing directly LaTeX code into HTML documents, so that complicated mathematical formulas may appear as embedded images on web pages.

Installation (Linux)

You need:

  • A complete LaTeX installation, including the documentclass slides.

  • imagemagick, the image manipulation suite.

Download f2ht.tar, untar it, and run the executable file install as root. If it is not executable, chmod it.


Open a plain text file and write your HTML code as usual. Whenever you need to include LaTeX code, simply put it between the tags <? and ?>. When you have finished, save the file as, say, mathpage, open a terminal, cd to the directory where the file is, and type f2ht mathpage. A directory named mathpage.dir will be created, containing index.html and a series of png images. You can place this directory, appropriately linked, at your web site. By default, the program uses the LaTeX packages amsmath and amssymb. If you need additional packages, edit the file /usr/local/etc/latexwrap (as root).


This piece of code will generate this page (you need the LaTeX packages color, pb-diagram and mathrsfs if you want to try out this particular example).

Kile and f2ht

You can use kile as a front end for f2ht, assuming you are willing to do away with latex2html. Go to Settings>Configure Kile>Tools>Build, select "LaTeXtoHTML", and in "General" change the "Command" to f2ht. Next, select "ViewHTML". In "General" change the "Command" to firefox. In "Advanced", fill in the following entries. "Target file":index.html, "Relative dir": %S.dir. After these changes, the build option "LaTeXtoHTML" will invoke f2ht. The button "ViewHTML" opens firefox in a new window showing the page you have created.