home Installation of Latex2html Last updated April 30, 2011. By Nasser M. Abbasi Contents 1 Installation on Linux 1 2 Installation on windows with MikTex 2.8 1 2.1 Installation steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.2 Some errors and possible solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Making your latex code latex2html friendly . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.4 log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3 installation on cygwin 9 3.1 log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4 References 12 This whole page can be also found in this PDF file. A plain text version is also available of this page 1 which was generated using the following catdvi command catdvi -e 1 -U index.dvi | sed -re "s/\[U\+2022\]/*/g" | sed -re "s/([^^[:space:]])\s+/\1 /g" > index.txt 1 Installation on Linux Installation of Latex2html is very easy on Linux. Used package manager (GUI interface) and select latex2html package. It will install everything needed. Once latex2html is installed, I then created a file called $HOME/.latex2html-init This is my copy of my .latex2html-init 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. 2 Installation on windows with MikTex 2.8 After struggling with installation of Latex2html (l2h) on windows for many days, I have decided to write down the final layout showing graphically what the tree looks like. I think a graphical illustration to describe the installation is easier for me, and I suspect for many others, to see where things are. 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. click to enlarge 1 Thanks to http://zanedp.livejournal.com/201222.html for the full catdvi command used to conver this page to plain text 1 2.1 Installation steps The following are the main points to watch out for in order to minimize installation problems 1. Install the software components needed on the same drive, where your data is and where you will be working, because if you install the software on the C: drive, and your data is on another driver, then you will find that things might not work (this was in my case). 2. Start by downloading all the software components and install them one after the other. These are the components needed and where I downloaded them from * MikTex: Version 2.8 http://miktex.org/ * Perl: Active Perl 5.1 build 1006. http://www.activestate.com/activeperl/ * netpbm for windows: Version 10.27. http://gnuwin32.sourceforge.net/packages/netpbm.htm * gsview: version 4.9. http://pages.cs.wisc.edu/ ghost/gsview/get49.htm * ghostcript. I used AFLP ghostcript. I had problems with other versions for some reasons. May be there was something else going on, but this version works for me, so I am not going to change anything now. http://pages.cs.wisc.edu/ ghost/doc/AFPL/index.htm * latex2html version 2008 http://www.ctan.org/tex-archive/support/latex2html/ 3. Now install MikTex, perl, netpbm, ghostcript, gsview into the directories as shown in the tree. 4. untar latex2html into folder latex2html-initial/ 5. Edit latex2hml-initial/prefs.m and add/change the corresponding lines as the following $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'; 6. Edit latex2html-initial/config.bat and add/change the corresponding lines as the following set PERL=c:\texmf\perl\bin\perl.exe 7. Add the following to the PATH environment variable on windows (Using Computer->Properties- >Advanced) C:\texmf\latex2html\bin; c:\texmf\perl\bin; C:\texmf\GnuWin32\bin; C:\texmf\MiKTeX2.8\miktex\bin 8. Add a new environment variable GS_LIB and give it the following value .;C:\texmf\gsAFLP\gs8.54\lib;C:\texmf\gsAFLP\fonts Notice 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. 2 9. Add a new environment variable RGBDEF and give it the following value C:\texmf\latex2html\styles\rgb.txt 10. There is no need to define an environment variable TEXINPUTS since install.bat when run will copy the latex2html style files and put them in location within MikTex folder where they can be located by MikTex latex.exe without the need to define such an environment variable. 11. Start a new DOS terminal to make sure the effect of setting the above environment variable is now in effect. 12. There is one bug that shows up if you are using the package amsmath which causes the generated 2 HTML to contain extra text showing up inside the images. To fix this , cd to the folder G:\texmf\latex2html-initial\styles note: the this file on my linux box was located in /usr/share/latex2html/styles/more_amsmath.perl and 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 = ';SPMnbsp;;SPMnbsp;;SPMnbsp;' } $*=0; + $scan =~ s/($comment_mark\d+) /$1\n/g; if ($labels) { $labels =~ s/$anchor_mark/$tag/o; ($labels , $scan); ----- To here ----- 13. cd back to latex2html-initial/, run config.bat. If no errors then go to the next step. 14. run install.bat. Now latex2html will be installed to C:\texmf\latex2html 15. run latex2html-initial/test.bat and look for any errors. 16. If all is well, that is all. Now you are ready to use latex2html. Go to next step 17. Perform post installation configuration. Edit the file c:\texmf\latex2html\l2hconf.pm $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; 2 Thanks to Shigeharu TAKENO for finding the solution to this bug and posting it to the latex2htlm mailing list on 11/3/2009 3 18. On Linux/Unix system, the above commands can be put in ~/.latex2html-init file. If you do that, make sure to end the file with "1;" This is my file as an example cat .latex2html-init $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; $DVIPSOPT = '-E'; $LATEX_COLOR = ""; 1; 2.2 Some errors and possible solution 1. If you get this error when running test.bat that looks like something as the following pstoimg.bat: Error: Ghostscript returned error status 1 pstoimg.bat: Error: Couldn't find pnm output of G:\texmf\tmp\l2h1716\image002.ps Then check that you have defined GS_LIBenvironment variable correctly to point to the ghostscript lib/ and font/ directly as shown above. 2. if you get an error from test.bat that looks like something as the following pstoimg.bat: Error: pnmtopng.exe -interlace -trans gray85 < p3704.pnm > img1.png" failed: No such file or directory Then make sure that you have defined the env. variable RGBDEF as described above. 3. some of the bitmap images produced for the mathematics in the document have a solid dark bar, usually at the bottom or the side of the bitmap image. The reason for this is unknown. But I found by trial and error that setting the following values in my l2hconf.pm eliminated most if not all of these $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. See also this page https://ccrma.stanford.edu/ jos/webpub/Eliminating_Black_Rules_Equation.html which mentions a solution to removing black bars from under equations. 4. Some mathematics equations are still underlined, even after doing the above. I found this was the case when I was using linux. If you still see the underlines, then try the following: edit l2hconf.pm and set the value of DVIPSOPT as follows 4 $DVIPSOPT = '-E' ; 5. Some mathematics formula have gray color in background. I noticed this on some equations having gray background. In this case, edit l2hconf.pm and set the following: $LATEX_COLOR = ""; The above should remove the gray background. If the above does not remove the gray background 3 then try the following: In your latex document itself, add the following 2 lines in the document preamble \usepackage{color} \pagecolor{white} Then try again. This should, hopefully, remove the gray background. The above trick did it for me when I moved to new Linux OS and found the gray background came back, even though I was using the same .latex2html-init file as before. 6. Watch out for the -no_resuse option to latex2html. If one is also using -no_subdir, then La- tex2html will ask the user if they want the images in the current folder deleted: 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. 7. l2h does not support the package ragged2e. I use HTML CSS style to change the alignment of the table cells. The following code will not work as expected in l2h \documentclass{article} \usepackage{html} \usepackage{array} \usepackage{ragged2e} \newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} \begin{document} \begin{tabular}{|P{2in}|P{2in}|} %notice UPPER case P here \hline jfadlkfj lkfjdsl fdasfad fkjdsklfja& djflkjads;flkajds;flk dsafjdads\tabularnewline\hline jfadlkfj lkfjdsl fdasfad& djflkjads;flkajds;flk dsafjdad\tabularnewline\hline \end{tabular} \end{document} 8. some issues with Latex2html some_issues_latex2html_2008/index.htm 3 Thanks to post by Ross Moorehttp://www.tug.org/pipermail/latex2html/2000-October/000805.html 5 2.3 Making your latex code latex2html friendly These are few things that I found that helped in using latex2html 1. Always include html package \usepackage{html} 2. l2h does not support tabularx package. As a work around add the following to the preamble %\begin{htmlonly} %\newenvironment{tabularx}[2]{\begin{tabular}{#2}}{\end{tabular}} %\end{htmlonly} In addition, l2h will not recognize %\raggedright so it has to be removed. 3. l2h does not support listings.sty, therefore if the latex code already does something as \lstinputlisting{file.txt} 4 then it will not work with l2h. The solution is to add the following %... %\begin{htmlonly} % \usepackage{verbatim} % \providecommand{\lstinputlisting}[2][]{\verbatiminput{#2}} %\end{htmlonly} %..... %\begin{document} %... %\lstinputlisting{file.txt} %... %\end{document} I found one problem in the above. If the file has an absolute path on it, then it will not be included. But if the file is in the same folder as the latex file, then it will be included. So, the following will not work %... %\begin{htmlonly} % \usepackage{verbatim} % \providecommand{\lstinputlisting}[2][]{\verbatiminput{#2}} %\end{htmlonly} %..... %\begin{document} %... %\lstinputlisting{/home/my_files/file.txt} %... %\end{document} 4. Some images that I use were too large for inclusion in PDF without being scaled, even though the size looked OK for html. 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. 4 Thanks to post by Ross Moore for this solution 6 % \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} 5. Wanted a way to modify the
META tags in the HTML file generated by latex2html. I settled on this method for now. May be there is a better way? Thanks for old posts I found on the net by Thomas Anders and Ross Moore which helped in finding this solution. (a) created a file called l2h_init.pl in the same folder where my latex file is. This file looks like this $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; "\n" . "\n" . "\n" . "\n" . "\n" . "$MY_META" } if $_; } 1; # This must be the last line (b) Now run latex2html to convert my latex file to html. Supposed my latex file is called foo.tex, then the command I used is latex2html -init_file l2h_init.pl foo.tex (c) now I looked at the generated HTML file foo.htm, and I see the header as follows