Chapter 40
Commands for Producing HTML Output

This section describes commands which can be used to display formulas and expressions in HTML files. This is done by creating gif files to display formulas and expressions that can not be displayed in plain text.

40.0.4 ToHTMLString[expression]

Aliases: HTML
Description: Convert an expression to a Mathematica string which is a series of HTML image tags. These tags call gif images which are made from the latex version of the symbols in expression. If the proper gif does not already exist, then ToHTMLString will try to create it and put it in the directory specified by the Mathematica variable $GifDirectory. If the gif is created, then ToHTMLString will record the HTML tag in a file so that it will not have to be created again. ToHTMLString can be used to create a large assortment of symbols which can be used over and over.
Arguments: expression can be almost any Mathematica expression, like a symbol, list, rule, or polynomial.
Comments / Limitations: If the user does not have write access to the $GifDirectory, then the resulting gifs can not be saved. The HTMLHardWired.m file should be in the current working directory in order to save the new HTML tags so that the gifs do not need to be created again. ToHTMLString uses the following external programs to create the gifs. Latex, dvips, pstogif and giftrans.

40.0.5 MakeGif[file,expression]

Aliases: None
Description: Creates a gif image which is the latex version of expression. Unlike ToHTMLString, MakeGif only produces one gif file. No attempt is made to save the HTML tag in a seperate reference file.
Arguments: file is a string which will be the name of the gif file. expression can be almost any Mathematica expression, like a symbol, list, rule, or polynomial. If expression is a string, then no attempt is made to convert it to TEXform. This is good for complicated expressions if the user is familiar with TEX. MakeGif tries to display the result with xv by default. The option DisplayFunctionstring will attempt to view the gif with the command string. DisplayFunctionIdentity will not display the gif.
Comments / Limitations: MakeGif uses the following external programs to create the gifs. Latex, dvips, pstogif and giftrans.

40.0.6 HTML

HERE IS ANOTHER ACCOUNT OF THIS MATTERIAL

THEY SHOULD BE MERGED SOMEDAY

This options creates a directory with several files in HTML format. This was constructed before Mma 3.0 and has not been tested for compatibility with it. The spreadsheet file is called index.html, and there is a seperate file for every category. There are several complications which makes this option impractical. The indeterminates, which contain subscripts and superscripts, are stored as gif files. These gif files are created with latex, dvips, pstogif and giftrans. The command which creates them needs to know what directory they are stored in. Also, the HTML text which calls the correct gif file needs to be stored in a Mathematica file. When an indeterminate is used for the first time, the HTML text needs to be added to this file. This means that the user needs write access to this file. Most computer systems can be set up to handle these idiosyncracies, but not without some effort.

Here is a brief overview of what would need to be done. There are several gifs already created. They are in a directory called GifDirectory?? in the directory containing the Mathematica source code for NCAlgebra. If you do not have write permission, then copy this directory to someplace where you do have write permission. Also, put the file HTMLHardWired.m someplace where you have write permission. It would be best to put it in your current working directory. Adjust your Mathematica $Path variable so that this copy of HTMLHardWired.m will be loaded. When that doesn’t work, send us e-mail at ncalg@osiris.ucsd.edu.

40.1 Using an input file

Because Mathematica is interpretive, it is tempting to perform computations by starting Mathematica and start typing. Often, however, we have found that it is often the case that it is helpful to construct an auxilary file and then to load that file. This has the benefit of allowing the user to modify the computation slightly and rerun it, as well as the additional benefit of recording the computation.

A common input file may have the form

First version of the file
Get["NCGB.m"];  
start = {x**x-a,  
         Inv[y]**y-1,y**Inv[y]-1,  
         (1-x)**Inv[1-x]-1,  
         Inv[1-x]**(1-x)-1  
};  
start = NCExpand[start];  (* NCExpand, alias NCE is explained in the NCAlgebra document. *)  
Print["start:",start];

After the file is run, one can see whether or not the file executed correctly. It does not — we forgot the SetNonCommutative command. The new file would look like:

Second version of the file
Get["NCGB.m"];  
SetNonCommutative[a,x,y,Inv[x],Inv[1-y]];  
start = {x**x-a,  
         Inv[y]**y-1,y**Inv[y]-1,  
         (1-x)**Inv[1-x]-1,  
         Inv[1-x]**Inv[1-x]-1  
};  
start = NCExpand[start];  
Print["start:",start];

After restarting Mathematica and running this command, we find that start is what we expect it to be. We can then remove the Print statement and add more code.