Scripsit Ben:
>a<sup>2</sup><sub style='position: relative; left: -.5em;'>i</sub?
It works - very nice! Thank you,
Unfortunately, that's mostly an illusion. Test it using different fonts and
different browsers, and you'll probably see many variants ranging from very
nice to really awful, like the superscript and the subscript overlaid.
When you shift the subscript to the left - which you can do with other
techniques as well (see e.g.
http://www.cs.tut.fi/~jkorpela/math/#subsup ),
you need to make a guess or an estimate on how much it needs to be shifted
to reach the same horizontal position as the superscript. The real effect
depends on the font, and using the em unit does not solve all the problems
here.
So you need to be careful, and the results will still vary, though perhaps
tolerably. It is essential to vertical-align for sup and sub, since
otherwise the effects will be far too different on IE and Firefox (which
have rather different defaults for it).
From the HTML perspective, the basic problem is in that sub and sup elements
are defined in a rather presentation-oriented manner rather than
structurally. When you write <sub>i</sub>, you're saying that i is a
subscript but not what it is associated with. In the given case, "i" is a
subscript for "a" whereas "2" is a superscript (exponent) for the expression
consisting of "a" with subscript "i". There is no way to express this
structural relationship in HTML.
Andreas effectively suggested the safe approach of giving up the idea of
imitating the conventional mathematical notation and using parentheses to
indicate the structure. It unambiguously indicates the meaning, though in a
style that differs from normal math texts. Other approaches involve various
risks, so you need to weigh the risks against the desirability of "math
style" rendering.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/