LaTeX, Lyx and latex2html under Windows 2000/XP

Partially revised March 2004

What follows was written in 2000…except for the red bits, which are up-to-date.

Yes, you can make it all work. It more or less works "out of the box". Perhaps the most important part is to make sure you are using the right version of Perl and Ghostscript for each job. I installed things in this order:

A Postscript viewer

Ghostscript and GSview from I'm currently using GSview version 4.3 and Ghostscript 7.04. These fully support TrueType as well as Postscript fonts, so you might want to invoke Ghostscript with the -sFONTPATH=C:/WINDOWS/Fonts switch to pick up all your normal Windows fonts in addition to the Ghostscript ones. Note also that the Postscript name of the Windows font will have all the spaces removed and, possibly, -Roman added to the end. So, for example, Humanist 521 BT becomes Humanist521BT-Roman. You can test this font with something like
      gswin32 -sFONTPATH=C:/WINDOWS/Fonts ../lib/
and then typing
      /Humanist521BT-Roman DoFont
in the Ghostscript window. You don't have to mess with the Fontmap at all. Of course, you don't get any intelligent TeX-friendly remapping of these fonts.

A LaTeX installation

MiKTeX from It's not quite as slick as Cygwin.I loaded "Small MiKTeX". It also works "out of the box". The command latex should now work in a Windows cmd box.

A set of UNIX-style tools, needed for LyX

Cygwin, from Just click on "Install Cygwin now" and follow the instructions. According to the LyX team, you need to install at least: ash, bash, bzip2, cygwin, diff, fileutils, gettext, grep, gzip, perl, , sed, sh-utils, tar, textutils. As I understand it, the perl installed here gets used by the LyX LaTeX import feature, but not by latex2html.

An X-server, needed for LyX

I use the X server that is now part of the Cygwin distribution. You will certainly want to read the Cygwin/XFree86 User's Guide

TrueType under X

You might want to use your existing TrueType fonts under X, for example to display them in the LyX GUI. There are a few steps here. You need to build ttmkfdir from Jörg Pommnitz which in turn needs FreeType1, an older version than that included with Cygwin. There is a compiled binary here for you to put on your PATH. You run this inside your windows font directory:
  cd /cygdrive/c/windows/fonts
  ttmkfdir > fonts.scale
  mkfontdir -e /usr/X11R6/lib/X11/fonts/encodings # These are standard parts of Cygwin
  xset +fp /cygdrive/c/windows/fonts              # As is this
You will now be able to see all the TrueType fonts in, say xfontsel. You can also use them as the Screen Fonts in LyX; Just go to Edit->Preferences->Screen Fonts and insert a new family, say "-*-comic sans ms". For our local Visual Identity I use "-*-palatino linotype" (from Windows XP) for Roman and "-*-humanst521 bt" (from Corel Draw) for Sans Serif. We have site licenses for both.

There are some extra notes on TrueType support, including enabling antialiasing, for Linux here.

Postscript fonts under X

If you also want to install extra Postscript Type 1 fonts, you can use the perl script type1inst, found in most Linux distributions, to build fonts.scale (and Ghostscript's Fontmap).

General Cygwin/X oddities

  1. Set some environment variables:
          export LC_ALL=en_GB.ISO8859-15  # Should tell the C library we are in the UK and use the € symbol
          export LC_CTYPE=en_GB.ISO8859-15  # But actually we have to do this too
          # You might need to export LANG LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
          # and LC_IDENTIFICATION with the same value too.

  2. Change the fonts used by xterm to something like
    by, for example, starting it as
        xterm -fn -misc-fixed-medium-r-normal-*-*-120-*-*-c-*-iso8859-15

export LC_CTYPE=en_GB.UTF-8
export LC_ALL=en_GB.UTF-8
export LANG=en_GB.UTF-8
xterm -u8

and in the new xterm type

less UTF-8-demo.txt

The demo file can be found here.

NetPBM, needed for latex2html

Instructions can be found at I simply downloaded the files,,,,,,, and into %ProgramFiles%\netpbm\ and created a couple of start menu items. One launches a command shell with %ProgramFiles%\netpbm\ added to the path and the other starts up the HTML help. The two shortcuts are:

	Command shell:
		Target: %SystemRoot%\system32\cmd.exe /K "PATH=%ProgramFiles%\netpbm\bin;%PATH%"
		Start in: "%HOMEDRIVE%%HOMEPATH%\My Documents\My Pictures"
	Help File:
		Target: "%ProgramFiles%\netpbm\man\html\index.html"
		Start in: "%ProgramFiles%\netpbm\man\html"

I have also modified the root man file so it picks up hyperlinks to the individual man pages. You can find a copy of mine here.

In order to make the NetPBM commands recognise colour names, you should copy this file to /usr/lib/X11/rgb.txt.

NetPBM installed in this way is good for batch image processing. Open the command window and construct a CMD-shell FOR command with pipes "|" and redirection ">" to do what you want. You can get help on FOR by typing FOR/? 

ActivePerl 5.6, needed for latex2html

Download it from I used the MSI installation and it ran without problems.

Finally, latex2html

Handle this step with care; there is lots to go wrong. There is some good background information here. First, get the distribution from I got version latex2html-2K.1beta. Unpack it into an empty directory and modify two lines in the file

	$prefs{'EXTRAPATH'} = 'E:\\PROGRA~1\\gs\\gs6.50\\bin;E:\\PROGRA~1\\netpbm\\bin';
	$prefs{'PREFIX'} = 'E:\\PROGRA~1\\latex2html';

The Perl scripts are unable to cope with spaces embedded in command paths, so it is important that the paths are "old DOS-style". It is also important that the netpbm and gs binaries not be on you path via a directory tree containing embedded spaces. The configure step will fail if these binaries are found via the wrong path. Now type 


Hopefully the script will progress to the line

	checking dvips version...

and hang. This is because the version of dvips that you are using prompts after printing version information. Type RETURN once. The script should then run to completion. You now need to modify

	$LATEX_COLOR = "\\pagecolor[white]{.7}";
	@IMAGE_TYPES = qw(gif png); # GIF is now default

The second change makes gif the default format for images. This is unfortunately necessary because of the continuing poor support for png from major browsers. The first change causes the images to be antialiased against a white rather than grey background. You should now test your configuration with 


Hopefully, all will be well and you will be able to view the output in your browser. Change the browser background colour and ensure that the background of the images of equations changes. If all is well, type


Go inside the installed copy of latex2html and comment out line 212, the second line below:

	# the next line fails utterly on non-UNIX systems
	#$LATEX2HTMLSTYLES =~ s/~([^$dd$dd$envkey]+)/L2hos->home($1)/geo;

also insert the second line below; it makes the --help option work properly:

	my $script = $SCRIPT || $0;
	$script =~ s/Program Files/PROGRA~1/;

There is an odd little problem with dvips finding image files; unless you set the -nosubdir option, it runs in a subdirectory and can't find the .eps files. A crude patch can be made by inserting ".." in the dvips search path. Modify the file \texmf\miktex\config\miktex.inf:


Lastly, Click Start->Programs->MiKTeX 2.1->MiKTeX Options, click on the Roots tab and add E:\Program Files\latex2html\texinputs.

Hints and tips

  1. There is some of the usual filename confusion:

    The upshot of this confusion is that relative file paths usually work fine. You cannot, however, use lyx to enter paths to, say, images that start with a / (because that will typically resolve to C:/cygwin) or include an explicit drive letter.

    There is a simple and uniform solution to all these problems. Names of the form 


    work correctly everywhere except at the CMD command prompt. They even work there if the "/" are replaced by "\". This rather odd path syntax is a standard Windows feature. You should use it for all absolute paths in LyX, LaTeX and latex2html.

  2. There are sometimes installation problems with paths containing embedded spaces. You can normally use PROGRA~1 whenever you might wish to use "Program Files".

  3. dvips is claimed to respond badly to output paths containing embedded "."s (periods).

  4. To get a simple flat rendering of a document into HTML, try

	latex2html -split 0 -nonavigation -noinfo -noaddress FIMENAME.tex