Up: Home

LaTeX Lesson 10:
Putting LaTeX on the Web

If you have a mathematical document that you want to put on the Web there are several ways that you can do it, and more ways are coming soon. Let's suppose that you have a LaTeX document with some mathematical formulas but without included graphics. Suppose also that you have a Web page where you would like to post the document. You might create a file, put it in the directory with the Web page where you want your document posted, make the file world-readable, and put a link to the file in the Web page. Starting with your LaTeX source file, you produce a DVI file and then use dvips with the -o option to produce a PostScript file. Here are some obvious choices for posting your document.
  1. link to the LaTeX source file
  2. link to the DVI file
  3. link to the PostScript file

In addition, there are several ways to produce a file in Adobe's portable document format, a "PDF" file, so you could also link to the PDF file.

After you read the following analysis of several ways of posting a LaTeX document on the web, you will construct links, as above to the files corresponding to your LaTeX document on completing the square.

If you choose to post your document by constructing a link to the LaTeX source file there are two main problems to face. First, the recipient must have access to LaTeX-2e. Second, the recipient needs access to whatever style packages and fonts you used in your document. Third, if your document includes graphic images, you would need to provide image files. You could overcome part of the first objection by building a file that includes all of your personal style files, but the recipient still would need access to LaTeX-2e and to any image files that you want to include in your document. It would be better if the recipient were knowledgeable about LaTeX.

Similarly with linking to the DVI file, the recipient would need a device driver (like dvips) installed on his computer to be able to "read" the DVI file. Device drivers are freely available, but not every machine has one installed. Moreover, any PostScript graphics to be included in the document would need to be provided separately, which would require extra links. In case the recipient is working in a UNIX environment, there is a good solution to this problem: you can produce a UNIX tape archive file (tar file). This solution might not help, however, if the recipient is not working in a UNIX environment.

Finally, a link to the PostScript file still requires that the recipient have special software to view the file. Although viewers such as Ghostscript and Ghostview are freely available, not everyone has immediate access to them. Also, PostScript files tend to be large. Linking to the PostScript file does have one big advantage: all of the graphics are included.

I know of three other ways that are more or less practical for putting a mathematical document on your web page by first converting it.

You can use the program "LaTeX to HTML" to convert the LaTeX source file to a collection of HTML files and graphics files. The software package latex2html, has been installed on our SUN servers. The program can take a long time to run, but you get html files that are convenient for posting. Equations are displayed as in-line images (GIF files), hence a source document containing lots of equations produces lots of image files. Before high-speed internet connections were common, the multitude of graphics files meant that the browser would often load the files slowly enough to be irritating. For anybody with a high-speed internet connection, that is no longer a problem. However, I find the appearance of documents generated by LaTeX-2-HTML to be far inferior to the PostScript version. Still, it is good to have an alternative to the other methods, one that does not require the recipient to have any software other than the browser itself.

Here is a link to a very simple HTML file produced by latex2html. This file has only text, but it should serve to indicate roughly the nature of the output. There are many web sites that have material posted in the form of HTML files that were converted from LaTeX by latex2html. One example is the LaTeX2HTML.org web site.

There is an online version of the user's manual for latex2html. available at the following URL:

  
  http://camden-www.rutgers.edu/HELP/Documentation/latex2html/manual.html
In addition, there is a file called README.CAMDEN at:
  
  http://camden-www.rutgers.edu/HELP/Documentation/latex2html/README.CAMDEN
that contains VERY important information about setting up your Unix shell to work properly with latex2html. The software consists of several programs and support directories all of which expect the directory /usr/local/latex2html to be on your path. If you need help, see the README.CAMDEN file

An alternative to using latex2html would be to modify the source file and to use hyperlatex.

Hyperlatex does a good job of providing both typeset documents and HTML documents from the same file, but it uses a subset of LaTeX commands augmented by some commands for producing links. It is available for free to use on UNIX systems. There are also several commercial programs available for translating LaTeX source files to HTML files. I don't know how well they work, but you can check out their examples by starting with a list from the TeX Users' Group or the TeX4ht home page.

An essentially different idea is to produce a file in Adobe's portable document format, a "PDF" file. Again, there is the problem that the browser needs help in reading the PDF file. However, Adobe makes their Acrobat Reader available for download without charge for several different operating systems, and it can be used as a "helper application" for various web browsers. There is an easy way to produce a PDF file. Simply run pdfLaTeX on your source file by typing pdflatex instead of typing latex. This results in a fairly compact PDF file, but there are some things that can be done in LaTeX but not in pdfLaTeX. For such occasions, when pdfLaTeX does not work, we can produce a PostScript file and then convert that to PDF.

Adobe's Distiller is supposed to produce a fairly efficient PDF file, but it is a commercial product which we seem not to have installed on the SUN servers. There is a free service on the Web that distills PostScript into PDF using a copy of Adobe's Distiller software. There is some information at the site with instructions for preparing a file to be converted.

One can also use the freeware GS converter ps2pdf, which is installed on the SUN servers, crab and clam. However, you may be surprised at the large size of the files that result from converting by ps2pdf. It seems that certain fonts are rendered efficiently and the rest are not. To get efficient PostScript it seems that we should arrange to use PostScript fonts rather than the standard bitmapped fonts. This is beyond my current expertise, but I was able to find some information, which may be useful.

According to The LaTeX Companion, dvips searches the file psfonts.map, which controls the mapping between font names used inside TeX and external names (for example, the Karl Berry names, which are used in the New Font Selection Scheme, NFSS, or the names of the original distribution of PostScript fonts by Y & Y). Then you should be able to edit the control file psfonts.map to replace the .pk versions of the Computer Modern font family with corresponding Type 1 fonts.

There is also a system called PSNFSS that provides a working setup of the NFSS2 version of the new font selection scheme. This system includes a number of packages: times, newcent, helv, palatino, etc. The safest choice seems to the times package, but then the Computer Modern math fonts may not match the text fonts. To overcome this visual mismatch of fonts, there is a package of fonts called mathtime and a package called pstimes that replaces the Computer Modern math fonts with the mathtimes fonts.

Those of you who have access to machines that are running Windows may check out the Netscape plugin from IBM, which allows Netscape's browser to render LaTeX files.


In Class Exercise: Post your essay on completing the square

First run LaTeX on your source file, and use the DVI file to produce a PostScript file by using the -o (output) option on dvips. Then run pdfLaTeX on your source file to get a PDF version of the typeset document. Move the LaTeX source file, DVI file, PDF file and PostScript file from your essay into the directory where you have your minimal Web page, and add links to them from the page, being sure to label the links so that the viewer can tell what to expect from following the link.

Configure your .cshrc file so that you can use LaTeX2HTML. The instructions are in the README.CAMDEN file for LaTeX2HTML. Now use LaTeX2HTML to convert the LaTeX source file of your essay, which will produce a subdirectory. Then link this material to your Web page.

Finally, run ps2pdf on the PostScript file to get a PDF version of your typeset file. If, as I suspect, it is uncomfortably large, you can gzip the file, and make a link to the gzipped version.


Finished?

If you have done all the above activities, and there is still time left, here are some other activities you can do.


Homework for after class

You probably will have time to start these during class.

  1. View each of the four links that you set up during class (to the LaTeX source file, the DVI file, the PDF file, and the PostScript file), and write a brief description of how each link worked. Be sure to say what machine and browser you used.
  2. Starting from one of your graphics test files, create and post the source file, PDF file, DVI file and PostScript file, as well as linking to files created by LaTeX2HTML.
  3. Write a description of how these new links work with a browser.
  4. Continue to work on project B.


/ Math on the Web / Projects /


Email: Martin L. Karel

Valid HTML 4.01!