ITS LOGO March 1997

How do I ... logo Use the Latex to HTML Converter


Contents


latex2html translates Latex (version 2e) source files into v3.2 compatible HTML (Hypertext Markup Language) suitable for viewing using World Wide Web browsers like Netscape's Navigator or lynx. This can be a useful tool if you need to maintain a document in a form suitable for high-quality printing as well as making it easily available via the Web. The program automatically translates figures and tables into images that can be displayed using most graphical web browsers

This document describes version 96.1c of latex2html, which is available on ITS Unix systems and via the /uwo/ccs/export tree for other campus unix systems. (See How do I... Install /ccs/export on a Unix System.)

Getting started

Since latex2html typically creates a number of HTML files from your latex source, you should create a directory in an area readable by the Web server (typically somewhere in the /usr/lib/www/ tree if you are using the central UWO Web server) to hold the HTML version of your document. This step is done once for each document being produced. For example, to create a directory for a tree identification manual named treeman.tex, you might use the command:

   mkdir /usr/lib/www/forestry/treeman
Before translating a Latex file into HTML, the source should first translate cleanly into a .dvi file using the latex command. While the .dvi file is not used directly by latex2html, it does make use of the .aux file also produced by the latex command.

Making the Translation

The most basic translation command simply takes a Latex file and produces an HTML version of that file in a specified directory. For example, to translate treeman.tex into /usr/lib/www/forestry/treeman/treeman.html with an HTML title of Tree Identification Manual, use the following command:

   latex2html -t "Tree Identification Manual" \
      -dir /usr/lib/www/forestry/treeman treeman.tex
This command produces a tree of HTML files in the specified directory where each file is a section of your document and navigation buttons (e.g. Next, Previous) are defined to allow your Web-based readers to move through your document. Note that the -t parameter is required to allow latex2html to produce a valid HTML <TITLE> tag. The URL for this example document would be:
   http://www.uwo.ca/forestry/treeman/treeman.html

Additional Command-line Options

There are a number of useful command-line options that allow you to modify the default behaviour of latex2html. A few of the more common ones are described here. See the manual (in More About latex2html below) for a full listing and more detailed explanations.

-split 0
This tells latex2html to leave the file as a single (long) HTML file rather than splitting it by section. This setting turns off the navigation buttons since they are redundant. It is typically used for documents that are article rather than book sized.
-show_section_numbers
This option includes the numbers in the HTML output. By default the Latex section numbers are not included. Note that latex2html has trouble generating section numbers for documents that are made up of multiple files that are included into a main file.
-address "address-string"
This HTML code is added to the bottom of each HTML page produced. The following is a useful example of this command which produces an address line suitable for official UWO Web pages (note that the single quotes in the following line are back quotes):
   -address "Peter Marshall, ITS, UWO \
     &lt;peter@uwo.ca&gt; \
     Last update: `/bin/date +%y-%m-%d\ H:%M` by `whoami`"
	
-contents_in_navigation
Includes an extra ``Contents'' button that allows readers to jump back to the Table of Contents for the document from each HTML page.

Getting Fancy

While latex2html can produce a adequate version of a printed document for Web display, a typical Latex document won't have a lot of what the Web is famous and perhaps most useful for: links to other documents and facilities. To embed the Web-only features described below into your document you need to first include the Latex extension package html.sty in your .tex file: Add html to the list of packages being used at the top of your document. For example:

    \usepackage{html}

Conditional Text

At times it is necessary to exclude a portion of the file for either the HTML or the paper version. Two Latex commands and two environments are defined to implement this:

\begin{latexonly} ... \end{latexonly}
\latexonly{...}
\begin{htmlonly} ... \end{htmlonly}
\htmlonly{...}
See the Example section below for an example of how this might be used.

Hypertext Links

Links to other documents on the Web can be included in Latex documents that include the html package. In the HTML version of the document they appear as hyperlinks while in the printed version the URLs appear as footnotes or just as plain text depending upon the command used.

\htmladdnormallink {link name} {link-URL}
This makes "link name" a hyperlink to the URL "link-URL" in the hypertext version of the document but no indication of this is included in the printed version.

\htmladdnormallinkfoot {link name} {link-URL}
In addition to making a link, this version of the command also adds a footnote consisting of the "link-URL" in the printed version of the document.

Here's two examples of hypertext links in latex:

\htmladdnormallink {ITS at UWO} {http://www.uwo.ca/its/}
\htmladdnormallinkfoot {UWO} {http://www.uwo.ca/}

An Example

As an example that uses some of the commands defined in the previous sections, here's some handy code that allows you to refer people to the on-line HTML version from the paper version and vice versa:

\begin{htmlonly}
This report is available in its entirety in a
\htmladdnormallink{PostScript version}  {treeman.ps} suitable for
either viewing or printing.
\end{htmlonly}
\begin{latexonly}
This document is also available on-line in hypertext format via the
World Wide Web as
{\tt <URL:http://www.uwo.ca/forestry/treeman/treeman.html>}.
\end{latexonly}

More About latex2html

A substantial (50+ page) manual that describes all of the options of latex2html is available either on-line as an HTML document at:

   http://www.uwo.ca/its/doc/manuals/latex2html/ 
or as a PostScript file suitable for printing at:
   ftp://ftp.uwo.ca/usr/doc/manuals/latex2html.ps
For a quick reference to the command-line options, see the Unix man page for this program:
   man latex2html

Your comments and suggestions are important; we welcome them.


©1997, The University of Western Ontario. Permission is granted to copy in whole or in part provided that due credit is given to the authors, the Division of Information Technology Services, and The University of Western Ontario.

ITS Documentation Team, UWO <doc-team@uwo.ca>
Last updated 1997-03-29