MATH 640-499 Class 18:
Tuesday, March 30, 1999
Putting LaTeX on the Web



REMINDER. If you have not done so already, please finish and hand in the assigned exercises from last week:
  1. Draftcopy: draft water-mark
  2. Picins: text flow around boxes
  3. Exam Package (from Hirschhorn)


Today's tips: repeat from last week

More about using the history list in UNIX

Recall the syntax for the history reference:

    !event:words:modifiers
In the example,
   !la:p
the event was "la", there was no "words" argument, and the modifier was "p", which "prints" the command without executing ( by "prints", here, one means "displays on the terminal"). The effect of running the command is to search the history list for the most recent command line that started with the string "la" and simply to display that command. Recall what the terms mean:
event
Here "event" means "command"
words
(Optional)If given, select words from the command, else use all words
modifiers
(Optional)If given, modifies selected words or event
Here is a variant of the example we had last time (Notice that the usual !! reference to the previous command gets shortened to just ! in these examples).
%  more some-file-with-a-long-name 
%  emacs !$ &
%  mail friend < !*
Here !$ gives the last argument of the previous command, whereas !* gives all arguments of the previous command. Since there is only one argument, !$ and !* have the same effect. However,
 %  dvips somefile -o somefile.ps
 %  latex !*
is going to generate an error message. To refer to the first argument of the last command you can use !^. To refer to the n-th argument of the most recent command containing enc you can use !?enc?:n. The n is called a "word designator", and is an example of the "words" part of the command syntax.
    !event:words:modifiers

On Monday's tips we saw the p example of a modifier. Another is the substitution modifier s. Example:

%  long-command | more          process something and view the result
%  mail friend < urgent.txt
%  !-2:s/more/lpr               do same process and print the result
long-command | lpr  (tcsh prints the command)
For modifying part of the previous command there is an abbreviated form: ^old^new. Thus,
%  mre somefile.txt             misspelled "more"
%  ^m^mo                        replace "m" by "mo"
more somefile.txt


In-class Activities

Search the Web

Find information on each of the following topics. You may do this as homework if you prefer, due Monday, March 23. Print out a sample of what you find, and hand in the printed copy with a note as to the URL for what you found, and your name.
  1. Artificial Life
  2. Cryptography
  3. Symbolic Computation

Putting documents 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

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 has to convert your source file, so must have access to LaTeX. Second, the recipient must have access to the same style packages and fonts that you used in your document. Third, if you wanted your document to feature included graphics, you would need to provide separate PostScript files. You could overcome part of the first objection by building a file that includes all of your personal style files, but the recipient would still need access to LaTeX and would have to be fairly 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 file. Although the device drivers are freely available, not every machine has one installed. Moreover, any PostScript graphics to be included in the document would need to provided by a separate link unless one were to take advantage of the possibility of producing a UNIX tape archive file (tar file). The UNIX tape archive file idea works reasonably well if the recipient is working in a UNIX environment, but may be a problem for recipients working in a different 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 them. Also, PostScript files tend to be large. The one big advantage to this method is that it takes care of included graphics.

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

You can convert the LaTeX source file to an HTML file, or rather, to a collection of HTML files and graphics files. To do that you can use the software package latex2html, which 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), which means that a source document containing lots of equations will result in lots of image files. Consequently, the person who wants to view your work may find the process of loading the files to the browser to be slow.

The latex2html package has not been installed on our SGI network as of March 1999, but it may be installed next summer. Meanwhile, we can use the copy on the SUN network.

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 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 PostScript file and then convert it to 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 Netscape's browsers.

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 95 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

Move the LaTeX source file, DVI 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 three links that you set up during class (to the LaTeX source file, the DVI 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, 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.

/ Home / Contents /


email to:Martin Karel