#### Do you have a question? Post it now! No Registration Necessary. Now with pictures!

## Re: both sub- and superscript together?

On 7/3/2007 2:40 PM, Ben wrote:

Before anyone asks "Why?", note that having both superscripts and

subscripts on the same variable is not unusual in mathmatics (e.g., in

harmonic analysis).

--

David E. Ross

<http://www.rossde.com/ .

Don't ask "Why is there road rage?" Instead, ask

"Why NOT Road Rage?" or "Why Is There No Such

Thing as Fast Enough?"

<http://www.rossde.com/roadrage.html

## Re: both sub- and superscript together?

David E. Ross wrote:

...

Maths and chemistry tend to leave the simple (sequential) text

formatting capabilities. I also vaguely remember 6 pre/post/above/below

sub/superscripts, developed for an international standards project...

If you can't find an appropriate representation in Unicode, you better

may use a graphical representation, or a specialized display object.

DoDi

## Re: both sub- and superscript together?

Scripsit Ben:

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/

## Re: both sub- and superscript together?

If you add a span:

a<span class="xscript"><sup>200</sup><sub>i</sub></span>

you can use:

span.xscript {

position: relative;

}

span.xscript sub {

position: absolute;

left: 0.1em;

bottom: -1ex;

}

You might find the small left value is not to your taste. Of course,

all hell breaks loose if the subscript is longer than the superscript.

I feel sure there are better solutions -- I just can think of any

right now.

--

Ben.

## Re: both sub- and superscript together?

On Tue, 3 Jul 2007, Ben wrote:

Use parentheses:

(a<sub>i</sub>)<sup>2</sup>

http://www.unics.uni-hannover.de/nhtcapri/mathematics.html

http://www.cs.tut.fi/~jkorpela/math /

--

In memoriam Alan J. Flavell

http://groups.google.com/groups/search?q=author:Alan.J.Flavell

## Re: both sub- and superscript together?

Depending on the audience I'd consider rendering LaTeX into an img and

add an alt attribute containing the LaTeX code, at least if you start

using more complicated formulae. A better alternative, if it was more

widely supported already, would be to use MathML

(http://en.wikipedia.org/wiki/MathML ).

Cheers,

Thomas Luzat

#### Site Timeline

- » filter:chroma messes up the whole page?
- — Next thread in » HTML Authoring Forum

- » great tool to help learn HTML
- — Previous thread in » HTML Authoring Forum

- » HTML 5 validation software?
- — Newest thread in » HTML Authoring Forum

- » Dell Battery Slice LED codes
- — The site's Newest Thread. Posted in » Laptop Computers Forum