[l2h] Workarounds for two bugs (equations with white margins, and more)

Ross Moore ross at ics.mq.edu.au
Wed Mar 16 02:23:27 CET 2005


Hello Daniel, and Armin, and others

On 16/03/2005, at 10:25 AM, Daniel Clemente wrote:

>> unfortunately it does not completely solve the problem:
>> - the white margin is indeed removed
>> - but my images are no more correctly centered on the baseline.

Exactly.

LaTeX2HTML deliberately adds the "padding" below images where
there is a non-zero descender; i.e., where there is ink placed
below the natural baseline of the mathematical expression.
Enough padding is added to equalize the height and depth,
so that there can be exact alignment at the the middle of
images placed next to each other.

Furthermore, the  "align=middle" used to mean that the images
would align their middle with the baseline on the surrounding
text. This worked perfectly with Netscape versions up to 4.xx .

It did not work so well with IE, since someone there decided
that "align=middle" means align with the middle of the text,
rather than with its baseline.

While that may seem logical, in some sense, it is actually
quite absurd --- as there is no consistent concept of what
is the middle of a line of text.
For example, the alignment changes with the font-size,
whether there are uppercase letters, whether there are letters
at a different size to others (e.g. via <FONT size=...> tags,
perhaps even according to whether there are some letters
with descenders (j,p,q,y) not to mention fancy fonts.

Indeed by just widening the window to allow more text onto
a line containing an image (of inline-math, say) you could
see the vertical positioning of the image change,
as uppercase letters first move into that line.



Then with more recent versions of Netscape/Mozilla, they
decided to interpret "align=middle" in the same way as IE.
Bug-reports were lodged, pointing out the error in this
approach; and there has even been an acknowledgement
that the new strategy is indeed a *bug*.
But nothing seems to have changed in Mozilla or Firefox.

Some other browsers continue to "do it right".
So you cannot rely on adopting image-making strategies
specifically to make things look good in Mozilla or IE.



Since HTML itself is essentially a frozen technology,
it seems that the only way to recover correct aesthetic
positioning of images, for all browsers, is to use CSS rules.

If a general rule will work, then great.
Please tell me what it is, and I'll program LaTeX2HTML
to always add it, at least when creating pages for
HTML version 4.0 and later.


If it needs a separate rule for each image, according to
its TeX height and depth, then that's a lot harder to program.
It'll mean tagging each image with an ID, and including a line
in the .css file for each image. It'll also mean updating
the .css file on *every* run, in case the ID labels change
due to the most recent edits. This requires more substantial
changes to how LaTeX2HTML currently works, and will mean that
the size of .css files can grow enormously, resulting in
longer download times.


>
>    Hi,
>
>    in fact I also saw that problem; the dirty solution was to manually
> change the ALIGN attribute of those IMGs. You can do it quickly in
> CSS:
>
>   img[align="MIDDLE"] {vertical-align:bottom;}

That's certainly not going to align the baseline of the text with
the (optical) baseline in images; e.g. for fractions, integrals,
derivatives, script-letters, etc.


>
>    I should have to understand the implications of the line I removed;
> until then, there will be only hacks. Of course, any TeX master can
> help detecting whether there is a problem in margins, and what does
> cause it.

TeX has already solved the "problem in margins".
It's the browsers, who changed the rules from the original
HTML recommendations, that have stuffed up the alignments.

>
>    Thanks for the testcase (I have linked it on my web).



>
>    Daniel Clemente.
>    http://www.danielclemente.com/linux/l2h.html

Your first example (of  $\lnot P \Rightarrow Q$ )
aligns perfectly in the Safari (MacOS X) browser.
The padding is needed due to the descender in the 'Q'.
When the padding is removed, as in the 2nd image,
then it is placed too low, aligning the baseline of the
text with the middle of this image --- clearly wrong.

Viewing the same page in FireFox v1.0 (Macintosh), it is
the first image that is positioned too high,
with the 2nd image looking quite fine.


Your proposed solution, of altering the TeX coding that
is put into  images.tex  by LaTeX2HTML, is simply not
the correct approach to tackle this issue.
It will work for some images, when viewed using some
browsers, but otherwise just creates more problems
with other images and browsers.



Hope this helps,

	Ross Moore


------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114
------------------------------------------------------------------------



More information about the latex2html mailing list