[l2h] L2H 99.1 Error in Size of Pictures was correct in L2H 98.1p)

Ross MOORE Ross MOORE <ross@ics.mq.edu.au>
Sat, 22 May 1999 14:29:33 +1000 (EST)


> Bug in LaTeX2HTML 99.1 - Imagesize computed wrong
> 
> Appended is a complete minimal example that shows how l2h 99.1 does 
> something wrong, l2h 98.1p did right.
 
Well, actually it was 98.1 that was doing it wrong,
but giving you (erroneously) what you actually wanted.
There is a full explanation below.

> Description of the error:
> 
> the document bug2.tex contains one picture, bild.1, which  is - for 
> simplicity a figure originally createe
> with MetaPost and included in  the document as EPS file.
> The dimension of the picture  is exactly a square.
> In order to prove that, it is wrapped with a framebox construct.
> 


> While the correct 98.1p version yields an image dimension of 151x151, i.e. 
> a real square,,
> the new 99.1 version yields 151x296, i.e. a rectangle with height almost 
> double the width.
 
The double width comes from the fact that the TeX box containing
your image has a non-zero depth. For such an image to align
correctly with text on the same line, then <IMG ALIGN="MIDDLE"
must be used in the HTML code. For this to work, the depth of the
image has to be blown out to match the height --- this is why your
image become almost (but not quite) twice the height expected.


However, in your case there is no text on the same line as the image,
so this effort to get correct alignment is completely wasted.
Indeed it produces an effect that you do not want.

LaTeX2HTML does cannot tell that the alignment is redundant.
In short, your LaTeX source is ambiguous on this point.
In TeX parlance, you are creating an \hbox which can be set
in either vertical or horizontal mode; in fact horizontal with
the code you employed, though vertical is more appropriate to
what you actually want. (LaTeX2HTML has done the correct thing
for an image in horizontal mode.)

To resolve this ambiguity, LaTeX2HTML provides the {makeimage}
environment, defined in html.sty.
This crops an image to the smallest size to contain the ink placed by TeX/LaTeX.
This sets the contents inside a \vbox, so does not have to handle
alignment with surrounding horizontal-mode material.


See the following page, where the result is shown for your image:

http://www-texdev.mpce.mq.edu.au/BILD/bug2/bug2/node1.html

Your image appears 3 times;

1st: as you had it, in horizontal mode:

	\framebox[1.0 \width]{\includegraphics{bild.1}}

2nd: within a display-math environment:

	$$\framebox[1.0 \width]{\includegraphics{bild.1}}$$

3rd: using {makeimage}:

	\begin{makeimage}
	\framebox[1.0 \width]{\includegraphics{bild.1}}
	\end{makeimage}


The 2nd and 3rd cases give the correct height to your image...

...*and* the left side of the \framebox is not accidentally
cropped away.




> Analysis of the error:
> The bug has nothing to do with the creating of the .gif file. It is already 
> there
> in the auxiliary fil images.tex.
> 
> I ran images.tex through latex and dvips (or xdvi) and got the same error:
> See files test99/images.* and test98/images.*

> I see that the file images.tex looks quite different in version 99.1 thatn 
> in 98.1p,

That is because you can see the cropping-bars that are used to capture
the white-space needed to align the image using  ALIGN="MIDDLE"


> however I cannot easily identify any further the cause of the error.

There is no error; except that v98.1 didn't treat \framebox
correctly as an \hbox ; imagine setting the following

	"... some \framebox{framed text} here..."

In v98.1 the baseline of the text would not align.
With v99.1 it now does align, at the cost of extra depth in the image.


> 
> Of course in my real case the distortion does much more harm than in this 
> example.

Sure. The solution is probably to use {makeimage} environments
within your source code. These are perfectly transparent to LaTeX,
but solve a critical problem for LaTeX2HTML.


 
> I am certainly willing to do my contribution to fixing the problem, but I 
> would prefer to get in contact with the
> author of the code that currently creates images.tex
> 
> How can I reach him?

You got him.
 
> Many thanks for your help: Walter Gull

You're welcome.
I hope my explanation is satisfactory to your needs.

	Ross Moore