LaTeX2HTML: Publish Science to the Web

 in
Tailoring math-intensive documents to fit the Internet.

Ironically, 20 years after the advent of the World Wide Web, it is still a struggle to publish math-intensive scientific documents on the Web. New standards like MathML have been out, but before the popular web browsers support them, the best way to reach a maximum audience is still to put math formulae as in-line graphics in HTML documents.

In the off-line world, TeX/LaTeX packages are known to produce the best formatted scientific documents. LaTeX is, in fact, a standard format for many academic journals. For scientists and researchers, the best of two worlds is to write in LaTeX and then publish on the Web. LaTeX2HTML is the perfect tool for that.

LaTeX2HTML originally was written by Nikos Drakos in 1993 as an open-source project. It was improved and enhanced by many members of the Open Source community. LaTeX2HTML converts LaTeX documents to standard HTML format. Since HTML is a text format, it converts all the nontext elements into in-line graphics. It is a Perl application and runs on many platforms including most flavors of UNIX/Linux and Windows.

In this article, I first give an example of how to convert a simple LaTeX document to HTML and discuss how the program handles in-line graphics and style files. I then explain the LaTeX2HTML-specific LaTeX commands/environments. Finally, I discuss a more creative use of LaTeX2HTML—using it on the server side. For simplicity, the term formula refers to anything that is in LaTeX's math mode. That includes simple in-text math symbols, “displaymath” formulae and numbered equations.

A Simple Example

The usage of the command is very straightforward. If you want to publish your LaTeX document, mydoc.tex, to the Web, you run

latex2html -local_icons mydoc.tex

LaTeX2HTML creates a new subdirectory (mydoc/) and puts all HTML files and image files in it. You can now copy mydoc/ under the document tree of your web server, and your document is available at http://yourserver/path/mydoc/index.html.

The title, headings and emphasized text are marked up properly with HTML tags. All the formulae/tables/figures and anything that normal HTML cannot display are converted into in-line graphics.

If mydoc.tex has several sections/subsections, LaTeX2HTML generates an HTML file for each section and a table of contents with links to each section. Each page has a navigation bar with links to next/prev sections and the table of contents. If you want only one big HTML file, use the -split 0 command-line switch.

LaTeX2HTML needs to know where to find the icon images on the navigation bar. The simplest solution is to use the -local_icons command-line switch, which instructs LaTeX2HTML to copy the navigation icons into the directory mydoc/. You also can use custom navigation icons by replacing mydoc/*motif*.gif files with your own.

In-Line Graphics

I use math formulae as an example to explain how LaTeX2HTML handles in-line graphics. It does the same thing for floating objects such as figures and tables.

LaTeX2HTML scans through mydoc.tex and extracts all math formulae into a file called images.tex. In images.tex, each formula is on a separate page. It then calls latex images.tex and dvips -S 1 -i to generate a one-page PostScript file for each formula. Ghostscript is used to convert and resize PostScript files into GIF or PNG images. LaTeX2HTML will remember the image names and insert the links back to HTML files generated from mydoc.tex.

There are several command-line switches to control the image generation process. For example, switch ps_images instructs LaTeX2HTML to use links to external PostScript files rather than in-line graphics.

Style Files

LaTeX2HTML handles style files differently for text and in-line graphics. LaTeX2HTML ignores any style file when it generates main text HTML files from mydoc.tex. However, style files often define new commands and environments that cannot be ignored. As a workaround, LaTeX2HTML allows users to rewrite the style file in Perl format. When LaTeX2HTML encounters a style file, it searches for the Perl translation and incorporates it into the main script. Fortunately, many popular style files already have been translated into Perl. To write such translations requires a working knowledge of the LaTeX2HTML internal structure. It is a difficult task, but you have the source code.

We want formulae, figures and tables to look exactly the same as they would print out on paper, with all the custom symbols, fonts and spacing. So, images.tex includes all the style files used by mydoc.tex. Since images.tex is processed by LaTeX, the style files are handled correctly.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: LaTeX2HTML: Publish Science to the Web

Anonymous's picture

HyperLaTeX is a very good one way to do it. Much pretty one for me.

The problem are the locales , but you can use LyX to do the frame and then build a skeletton to use HyperLaTeX. Ximo

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState