[l2h] problem with vertical alignment of inlined math images

Ross Moore ross at ics.mq.edu.au
Thu Dec 11 07:30:46 CET 2003

Hi Bruce, Peter and others.

On Thursday, December 11, 2003, at 01:24  AM, Bruce Miller wrote:

> Peter Morling wrote:
>> Hi,
>> there is a problem with the vertical alignment of inlined math images. 
>> In
>> 'internet explorer' the images is aligned correct according to the 
>> middle of
>> the text, but when using netscape, mozilla etc. images will be 
>> aligned a
>> little over the middle of the text alignment.

How the pendulum swings!

> Yes; surprisingly (to me) gecko (mozilla & newer netscapes) is getting
> this wrong.
> HTML's align='middle' should mean that the center of the image aligns 
> with the baseline of the surrounding text.  l2h generates the image 
> with enough padding on the bottom (or top) so that the middle of the 
> image corresponds
> to the baseline of the math in it.

Yes.  It used to be that Netscape got this right, and IE aligned 
according to the middle of the surrounding text.
(as the CSS way, described below).

However, this IE/CSS way *cannot* be correct for inline images, since
    1.  you don't know the height of the text in advance --- that's under 
the surfer's control;
    2.  the height varies according to the presence of CAPITAL letters 
and letters with descenders  (g,j,p,q,y);
    3.  simply resizing the window, forcing text to re-flow, causes the 
relative position of images to shift vertically
           ---- a quite absurd situation.

It is for these reasons that LaTeX2HTML continues to use the old 
Netscape interpretation of  "align=middle".
Any other is inherently impossible to predict how things will look.

> However, this attribute has been deprecated in HTML 4: the new prefered 
> way is to use CSS. CSS's vertical-align:middle is slightly different: 
> it says that the middle of the image should align with the middle of 
> the x-height of the surrounding text.
> [Gecko is treating HTML's align='middle' the same as CSS vertical-
> align:middle.
> There's a bug report at 
> http://bugzilla.mozilla.org/show_bug.cgi?id=192077 On top of that, 
> apparently, some versions of IE are doing right and some wrong! ]

I've noticed that recent versions of Netscape/Mozzilla have changed to 
the old IE/CSS way.
I'm glad they now realise that this is a bug.

It's amusing to know that IE may have switched to getting it right !

>> How do i solve this problem?
> That's the catch :>
> The CSS approach is preferable, I think: it generally requires less
> padding of the image (although it embeds an assumption about x-height!

If you specify *everything* with CSS, including the fonts and 
font-sizes, and window-widths,
then you can position images precisely.

But that forces readers to view pages only with a very specific geometry.
You lose the ability to freely adjust the window size and have all the 
text re-flow to match.
Also, the reader/surfer loses control of the font-size that is most 
comfortable for themself.

> but then images don't really work with variable text sizes anyway); I 
> believe both IE & Gecko based browsers get CSS vertical-align right;
> and CSS is too useful not to use, anyway.
> This would require adjusting latex2html's algorithm for boxing up 
> inline math images ---  I'm not too anxious to jump into that code 
> myself, at the moment ---  The rest is easy: replace " align='middle' " 
> with " class='inlinemath' " and add a line to the CSS:
>  .inlinemath { vertical-align:middle }

It's not clear to me that it is even desirable to do so.
The HTML code will become more complicated, requiring more attributes 
relating to layout
rather than to content.

> Or, wait for the mozilla folks to fix it.  From the bugzilla log, it 
> looks like after some initial resistance, they've accepted that it is a 
> bug.

     Agreed; it is a bug in the browser.

>> Best,
>> Peter
>> Programmer Peter Morling, University of Southern Denmark
>> Department of Statistics, Sdr. Boulevard 23A, DK-5000 Odense C
>> Phone (+45) 6550 3399
>> _______________________________________________
>> latex2html mailing list
>> latex2html at tug.org
>> http://tug.org/mailman/listinfo/latex2html

Thanks Bruce for keeping abreast of the issue.


> -- bruce.miller at nist.gov
> http://math.nist.gov/~BMiller/
> _______________________________________________
> latex2html mailing list
> latex2html at tug.org
> http://tug.org/mailman/listinfo/latex2html
ross at maths.mq.edu.au
Mathematics Department                                         office: 
Macquarie University                                                
tel:  +61 +2 9850 8955
Sydney, Australia                                                       
fax: +61 +2 9850 8114

More information about the latex2html mailing list