Latex2html

From CUC3
Jump to navigation Jump to search

The latex2html script takes a latex document, and turns it into an equivalent set of HTML pages - broken down by section and then subsection. It generates an index.html page linking to each section and subsection as can be seen for the OPTIM documentation, here. The script itself is available for download here.

Installing the script

As you are most likely installing the script on a workstation where you do not have root access, you need to slightly deviate from the instructions in the INSTALL file. Before you start the install process however, you need to fix some bugs! Firstly - you need to edit pstoimg.pin. When converting from pmn to png, the latex2html script tells the converter to use a transparent background colour of 'gray85'. Unfortunately, the new version of the converter does not accept this and so you need to use the correct hex code instead in pstoimg.pin, #D9D9D9.

Here are the before and after lines:

Before:

$trans_color = $TRANSPARENT_COLOR||'gray85';

After:

$trans_color = $TRANSPARENT_COLOR||'#D9D9D9';

In order to fix the next problem, we need to first run the configure script. As you don't have root access, you need to specify a different installation path for both the script, and the latex style files. This should be done as follows:

cd ~
mkdir texmf latex2html
cd ~/texmf
mkdir tex
cd tex
mkdir latex

This creates the directory structure we need. The configure script is then run as follows

./configure --with-texpath=/home/CRSID/texmf/tex --prefix=/home/CRSID/latex2html --enable-png --enable-eps --enable-gif

Assuming you don't get any horrific errors, you can now build the config modules using:

make

There is also a known problem where you get black bars at the bottom of equations and math mode characters in general. This is an artefact of the image processing....process. latex2html converts all math mode characters into images when making the html, and when the converter was updated, the script lost its ability to remove the temporary black lines it put in to help it identify the bottom of images. There is a more detailed explanation here, but for us, it boils down to editing l2hconf.pm.

Here again is the before and after code.

Before:

# Options for dvips as determined by configure
#
$DVIPSOPT = ' -Ppdf  -E';

After:

# Options for dvips as determined by configure
#
$DVIPSOPT = ' -E';

To test the perl scripts, you should now run

make check

and assuming you only get vague errors, you can safely run

make install

Voila! You should now have a working version of the script in ~/latex2html/bin :)

Using the script

You need to compile your latex file before you run the latex2html script. Assuming you haven't compiled it before, you need to do:

latex FILE.tex
bibtex FILE
latex FILE.tex
latex FILE.tex

This will put in all the references from the bib file(s). You then execute the script as follows:

perl ~/latex2html/bin/latex2html -local_icons FILE.tex

The output will be in a directory called FILE which you can then view with your browser! Good luck!