This whole page can be also found in this PDF file
Once latex2html is installed, simply create a file called $HOME/.latex2html-init
This is my copy of my file, which fixes some issues mentioned below.
In addition to the above, I had to edit the file /usr/share/latex2html/styles/more_amsmath.perl for the rendering bug described below.
That is all! now latex2html is ready to be used on linux.
The diagram below shows the final installed tree. This tree layout can be used as a guide for anyone who wants to install l2h on their windows system.
$prefs{'EXTRAPATH'} = 'C:\\texmf\\gsAFLP\\gs8.54\\bin;C:\\texmf\\GnuWin32\\bin';
$prefs{'PREFIX'} = 'C:\\texmf\\latex2html';
$prefs{'TEXPATH'} = 'C:\\texmf\\MiKTeX2.8\\tex';
$prefs{'TMPSPACE'} = 'C:\\texmf\\tmp';
set PERL=c:\texmf\perl\bin\perl.exe
C:\texmf\latex2html\bin; c:\texmf\perl\bin; C:\texmf\GnuWin32\bin; C:\texmf\MiKTeX2.8\miktex\bin
.;C:\texmf\gsAFLP\gs8.54\lib;C:\texmf\gsAFLP\fontsNotice that the above is sufficient to make latex2html happy as far as GS_LIB is concerned, and hence there is no need to edit the file cfgcache.pm and set this value there as well, which if you check the file now, most likely this variable will be empty
$cfg{'GS_LIB'} = q'';
but this was OK on my system, since it is now defined in an environment variable. But it should do no harm to also replace the above
with
$cfg{'GS_LIB'} = q'.;C:\\texmf\\gsAFLP\\gs8.54\\lib;C:\\texmf\\gsAFLP\\fonts';
Even though I did not have to do it on my system as I mentioned above.
C:\texmf\latex2html\styles\rgb.txt
G:\texmf\latex2html-initial\stylesand edit the file called more_amsmath.perl as follows
----- From here -----
*** styles/more_amsmath.perl.ORG Sat Dec 2 15:15:01 2000
--- styles/more_amsmath.perl Fri Oct 1 08:42:49 2004
***************
*** 95,100 ****
--- 95,101 ----
}
} else { $tag = ' ' }
$*=0;
+ $scan =~ s/($comment_mark\d+) /$1\n/g;
if ($labels) {
$labels =~ s/$anchor_mark/$tag/o;
($labels , $scan);
----- To here -----
C:\texmf\latex2html
c:\texmf\latex2html\l2hconf.pmand make any changes needed. The following are the changes I made to my l2hconf.pm to make the generate HTML and images look better for me.
$FONT_SIZE = "12pt"; $WHITE_BACKGROUND = 1; $LOCAL_ICONS = 1; $MAX_SPLIT_DEPTH = 4; $SHORTEXTN = 1; $ANTI_ALIAS = 1; $ANTI_ALIAS_TEXT = 1; $HTML_VERSION = '4.0'; $MATH_SCALE_FACTOR = 1.8; $DISP_SCALE_FACTOR = 1.0; $FIGURE_SCALE_FACTOR = 1.0; $TRANSPARENT_FIGURES = 1; $NO_SUBDIR = 1; $DISCARD_PS = 0;
pstoimg.bat: Error: Ghostscript returned error status 1 pstoimg.bat: Error: Couldn't find pnm output of G:\texmf\tmp\l2h1716\image002.psThen check that you have defined GS_LIB environment variable correctly to point to the ghostscript lib/ and font/ directly as shown above.
pstoimg.bat: Error: pnmtopng.exe -interlace -trans gray85 < p3704.pnm > img1.png" failed: No such file or directoryThen make sure that you have defined the env. variable RGBDEF as described above.
$MATH_SCALE_FACTOR = 1.8; $DISP_SCALE_FACTOR = 1.0;On my system, any value less than 1.8 for the above, with everything else is fixed, produced the side solid edges again. This problem needs to be fixed.
$DVIPSOPT = '-E' ;
$LATEX_COLOR = "";The above should remove the gray background.
latex2html -no_reuse -no_subdir foo.tex This is LaTeX2HTML Version 2008 (1.71) .... Cannot create directory .\: File exists (r) Reuse the images in the old directory OR (d) *** DELETE *** the images in .\ OR (q) Quit ?And if you select option (d) then it will delete all the images in the current folder. This can include any images that were not related to latex2html earlier runs at all, and it could be your own images that you did not want deleted. This happened to me, but I had a backup copy. So, if you intend on using -no_subdir then it is safer to not use -no_reuse.
So I wanted a way to use conditional logic so that when the latex file is run by pdflatex, it will scale the image, but when it is run by latex2html, the image is not scaled. I settled at this solution.
% \documentclass[]{article}%
% \usepackage{html}
%
% \begin{document}
%
% \begin{htmlonly}
% \includegraphics[]{image.png}
% \end{htmlonly}
%
% \begin{latexonly}
% \includegraphics[scale=0.75]{image.png}
% \end{latexonly}
%
% \end{document}
$MY_KEYWORDS = "Latex2html, HTML, MikTex";
$MY_DESCRIPTION = "This describes Latex2html";
sub meta_information {
local($_) = @_;
if (not defined $MY_KEYWORDS) { $MY_KEYWORDS = "$FILE"; }
if (not defined $MY_DESCRIPTION) { $MY_DESCRIPTION = "$_"; }
do { s/<[^>]*>//g;
"<!-- Do not edit here - edit TeX file $FILE.tex instead -->\n" .
"<META NAME=\"description\" CONTENT=\"$MY_DESCRIPTION\">\n" .
"<META NAME=\"keywords\" CONTENT=\"$MY_KEYWORDS\">\n" .
"<META NAME=\"resource-type\" CONTENT=\"document\">\n" .
"<META NAME=\"distribution\" CONTENT=\"global\">\n" .
"$MY_META" } if $_;
}
1; # This must be the last line
latex2html -init_file l2h_init.pl foo.tex
<HEAD> <TITLE>index</TITLE> <!-- Do not edit here - edit TeX file index.tex instead --> <META NAME="description" CONTENT="This describes Latex2html"> <META NAME="keywords" CONTENT="Latex2html, HTML, MikTex"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> </HEAD>
\href{}{} to make links. use \htmladdnormallink{name}{URL} instead. l2h does not support \href.
Remember to include the html package \usepackage{html}.
\fbox. This will cause the image not to show up correctly. i.e. do not do something as the following
\fbox{\includegraphics[]{image}}
But instead just write
\includegraphics[]{image}
Assuming you are at folder called A/ and you run l2h on a latex file called B.tex which contains hyperlinks to other places in your site, and these links are added so that they are relative hyperlinks. i.e. the hyperlinks are relative the folder A. When l2h process the file B.tex, it would by default create a sub folder and put the result into it. This folder is called A/B/.
However, from B/ the hyperlinks are now not correct as the case would be if the file was still in A/. Therefore, I now add the following option to my l2h command -no_subdir. This means the current folder A/ will contain all the output from the l2h run, which can make the folder too messy. However, this for me was a better solution than having to change all the hyperlinks in the latex file or to make them all absolute links (which I do not think is a good idea).
I think the correct solution is to make l2h behave the same way as when Microsoft WORD saves a document as a web page, where it would leave the html file at the same level as the word document, but would then create a special folder called document_files which contains all the images and other html files generated.
latex2html -style="myfile.css" myfile.tex
G:\ drive under
a folder I called LATEX and not under C:\texmf as I showed in the diagram, but as long as you have installed everything on the same drive, it does not have to be the C: drive and can be anything else.
> which latex
/usr/bin/latex
> latex -v
pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)
kpathsea version 3.5.4
> which pdflatex
/usr/bin/pdflatex
> pdflatex -v
pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)
kpathsea version 3.5.4
> cygcheck -c | grep -i tex
tetex-base 3.0.0-3 OK
> which perl
/usr/bin/perl
> perl -v
This is perl, v5.10.1 (*) built for i686-cygwin-thread-multi-64int
(with 12 registered patches, see perl -V for more detail)
> cygcheck -c | grep -i perl
perl 5.10.1-3 OK
> which gs
/usr/bin/gs
> gs -v
GPL Ghostscript 8.63 (2008-08-01)
Copyright (C) 2008 Artifex Software, Inc. All rights reserved.
> which pngtopnm
/usr/bin/pngtopnm
> cygcheck -c | grep -i netpbm
libnetpbm-devel 10.49.2-1 OK
libnetpbm10 10.49.2-1 OK
netpbm 10.49.2-1 OK
@ISA = load('L2hos', $^O);
with
@ISA = load('L2hos', 'unix');
$prefs{'TMPSPACE'} = '/cygdrive/G/LATEX/TMP';
./configure
Noticed that it did not use TMP defined above in prefs.pm, which is not I want TMP to point to. So I edited the file generated by running configure above, which is called cfgcache.pm located in the same folder, and forced it to use my TMPSPACE by changing the line as follows:
$cfg{'TMPSPACE'} = q'/cygdrive/G/LATEX/TMP';
make install
make test
cd to the test directory and check the output to make sure it is OK.
I installed cygwin 1.7.5 on windows 7 (64 bit OS), and when I run some
command which uses perl, I get the following error:
0 [main] perl 2528 C:\cygwin\bin\perl.exe: *** fatal error - Internal
error: TP_NUM_W_BUFS too small.
DETAILS:
I installed cygwin, all of it on windows 7, 64 bit os.
All went ok.
Then I installed latex2html, and I am trying to use latex2html under
cygwin, which uses perl. (latex2hml is a PERL script)
When I run latex2html command on some latex file, I get many of the
above errors each time perl is called:
$ uname -a
CYGWIN_NT-6.1-WOW64 me-PC 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 Cygwin
$ cygcheck -c | grep perl
perl 5.10.1-3 OK
perl-Error 0.17016-1 OK
perl-ExtUtils-Depends 0.302-1 OK
perl-ExtUtils-PkgConfig 1.12-1 OK
perl-Graphics-Magick 1.3.7-2 OK
perl-Image-Magick 6.4.0.6-2 OK
perl-libwin32 0.28-3 OK
perl-Locale-gettext 1.05-11 OK
perl-ming 0.4.3-1 Incomplete
perl-SGMLSpm 1.03ii-2 OK
perl-Tk 804.028-3 OK
perl-Win32-GUI 1.06-3 OK
perl-XML-Simple 2.18-10 OK
perl_manpages 5.10.1-3 OK
postgresql-plperl 8.2.11-1 OK
subversion-perl 1.6.11-1 OK
$
$make test
.....
Converting image #2
1 [main] perl 3104 C:\cygwin\bin\perl.exe: *** fatal error -
Internal error: TP_NUM_W_BUFS too small.
Error while converting image
This is the file where this error comes from Unix.pm
This is a more detailed error message:
> 262: my ($self,$cmd,$in,$out,$err) = @_;
> 263: carp qq{Debug (syswait): Running "$cmd"\n} if($Verbose);
> 265: my $status;
> 266: my $child_pid;
> 267: if ($child_pid = fork) {
> 268: $status = waitpid($child_pid, 0);
> 274: unless(exec($cmd)) {
> 0 [main] perl 4524 C:\cygwin\bin\perl.exe: *** fatal error - Internal error: TP_NUM_W_BUFS too small.
> 269: carp "Debug (syswait): Finished child process: #$child_pid\n"
> 270: if($Verbose);
> 271: $child_pid = 0;
> 272: return($?);
> exited L2hos::Unix::syswait
This document was generated using the LaTeX2HTML translator Version 2008 (1.71)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -init_file l2h_init.pl -info 1 -split 0 -reuse 1 -show_section_numbers -no_subdir -local_icons -style nma.css index.tex
The translation was initiated by me on 2010-07-03