473,396 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

both sub- and superscript together?

Ben
If you want to use both subscript and superscript *together*, how do
you make them align horizontally?

E.g., I want to have a^2_i (read in LaTeX), how do you make both '2'
and 'i' align horizontally? The usual way of doing it:

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

will make '2' appear before 'i'.

Thanks!

Jul 3 '07 #1
8 19209
On 7/3/2007 2:40 PM, Ben wrote:
If you want to use both subscript and superscript *together*, how do
you make them align horizontally?

E.g., I want to have a^2_i (read in LaTeX), how do you make both '2'
and 'i' align horizontally? The usual way of doing it:

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

will make '2' appear before 'i'.

Thanks!
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>
Jul 4 '07 #2
rf

"Ben" <be**********@gmail.comwrote in message
news:11**********************@q69g2000hsb.googlegr oups.com...
If you want to use both subscript and superscript *together*, how do
you make them align horizontally?

E.g., I want to have a^2_i (read in LaTeX), how do you make both '2'
and 'i' align horizontally? The usual way of doing it:

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

will make '2' appear before 'i'.
a<sup>2</sup><sub style='position: relative; left: -.5em;'>i</sub?

--
Richard.
Jul 4 '07 #3
Ben <be**********@gmail.comwrites:
If you want to use both subscript and superscript *together*, how do
you make them align horizontally?

E.g., I want to have a^2_i (read in LaTeX), how do you make both '2'
and 'i' align horizontally? The usual way of doing it:

a<sup>2</sup><sub>i</sub>
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.
Jul 4 '07 #4
David E. Ross wrote:
>>If you want to use both subscript and superscript *together*, how do
you make them align horizontally?
....
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).
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
Jul 4 '07 #5
On Tue, 3 Jul 2007, Ben wrote:
If you want to use both subscript and superscript *together*, how do
you make them align horizontally?
E.g., I want to have a^2_i (read in LaTeX), how do you make both '2'
and 'i' align horizontally?
Use parentheses:

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

http://www.unics.uni-hannover.de/nht...thematics.html
http://www.cs.tut.fi/~jkorpela/math/

--
In memoriam Alan J. Flavell
http://groups.google.com/groups/sear...Alan.J.Flavell
Jul 4 '07 #6
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
Jul 4 '07 #7
Ben
On Jul 4, 12:52 am, "rf" <r...@invalid.comwrote:
"Ben" <benjamin....@gmail.comwrote in message

news:11**********************@q69g2000hsb.googlegr oups.com...
If you want to use both subscript and superscript *together*, how do
you make them align horizontally?
E.g., I want to have a^2_i (read in LaTeX), how do you make both '2'
and 'i' align horizontally? The usual way of doing it:
a<sup>2</sup><sub>i</sub>
will make '2' appear before 'i'.

a<sup>2</sup><sub style='position: relative; left: -.5em;'>i</sub?
It works - very nice! Thank you,

Ben

Jul 5 '07 #8
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/

Jul 5 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Josh Armstrong | last post by:
I would like to setup a form that will log the users logging in to a db. The form and the Db will currently log the users if they complete the logon and get in. It will then log the entry, but...
1
by: Chris Belcher | last post by:
I have a unbound form with 2 subforms. It looks something like this _______________________________________________ | | | | | ...
2
by: Homa | last post by:
Hi, I have a Datagrid that uses as a shopping cart and have a checkbox template column in it. I can't add both OnCheckedChanged Event and onclick client script for it. I want to do two...
3
by: Karim | last post by:
I have a button that opens a new Window using client side Javascript. The button also has server side script (.._click) that saves some session variables to be used in the new Window. The...
2
by: Jeff | last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in the eNPTest02 directory of my localhost on my development machine. The database is on the web. ...
5
by: Aaron Ackerman | last post by:
I have a code snippet where if a certain condition is met it creates and loads an instance of a form and closes the active form that called the smaller one. The problem is when I call me.close it...
31
by: Kathy | last post by:
I would like to get the old and new value for a change made to a text box so that I can store them in a change history table. What is the best way to do this? I am just learning VB 2005; porting...
3
by: papalarge | last post by:
I have a VB.NET application that consists of a toolbar and a subwindow that I want to function together and not independently. So when I give focus to one, I want to make sure that the other is...
5
by: dancer | last post by:
How do I send results of a form page to both email AND a database. I have a page which works with this sub: Sub btnSendMail_OnClick(Source As Object, E As EventArgs) And I have a page which...
3
by: Phillip Taylor | last post by:
I have an interface called Lockable and an interface called TableObject. How do I make sure that any class which implements Lockable also implements my other, TableObject interface? Do I have to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.