[l2h] Relative URLs in png/gif images

Bruce Miller bruce.miller at nist.gov
Wed Jun 4 22:54:36 CEST 2003

Herb W. Swan wrote:
> LaTeX2HTML uses an absolute path name when including a gif or
> png image.  These absolute paths will break when the entire
> document is moved to a different location or a different server.
> Relative URLs would be more portable and appropriate if the user
> specifies an image path relative to the document.

I've lost track of which version is which (my RH9 installation includes
an odd, partly old version:
  This is jLaTeX2HTML Version 2002 (1.62) JA patch-1.4
but I would think the one you cite would include the modified
graphic(s|x) packages.

The _should_ generate a url to the image relative to the generated
page in cases like yours....
Unless perhaps the extra centering, or space, or probably the computed width=\foo
... or whatever is confusing latex2html enough that it's just punting to LaTeX
to process the entire environment.

Certainly in simpler cases, eg
it should discover the .png, possibly do some simple image processing
(eg rotations), copy the image to destination, if needed, and
generate a relative url to it.
(omitting the image type is preferred so both LaTeX, pdflatex, latex2html, etc
can find the most appropriate type)

I apparently don't have a decent/recent version to test on, but that's
the way it was _supposed to work when I wrote it ....
(wasn't it actually _your_ original code that I adapted!)

> I am using the following version of LaTeX2HTML (l2h):
> This is LaTeX2HTML Version 2002 (1.67)
> by Nikos Drakos, Computer Based Learning Unit, University of Leeds.
> My test program is as follows:
> -------------------------------------------------------------------------
> \documentclass[11pt]{article}
> \usepackage{graphicx}
> \usepackage{html}
> \DeclareGraphicsExtensions{png}
> \DeclareGraphicsRule{.png}{eps}{.bb}{`pngtopnm #1|pnmtops -noturn -rle}
> \newlength{\gifwidth}
> %
> %  The \showimage command displays a gif image in html,
> %  and a PostScript version of it in the ps document.  The optional
> %  argument 'width' overrides the natural width of the image.
> %
> %  Usage:  \showimage{image}{caption}
> %          \showimage[width]{image}{caption}
> %
> \newcommand{\showpng}[3][0.9\textwidth]{%
>     \setlength{\gifwidth}{#1}
>     \begin{figure}[htb]
> 	\begin{center}
> 	    \vspace{1ex}
> 	    \includegraphics[width=\gifwidth]{#2.png} \\
> 	    \caption{\label{#2}#3}
> 	    \end{center}
> 	\end{figure}
>     }
> \begin{document}
> I'm going to include a png image right here:
> \showpng{l2h}{The figure caption}
> \end{document}

More information about the latex2html mailing list