[l2h] Using a multiple-character superscript and amultiple-character subscript at the same time with anundesired horizontal displacement between them instead ofabove and below each other

Lawrence Patrick Somerville L_Pat_S at hotmail.com
Wed May 21 07:17:46 CEST 2008


According to the Internet reference 
http://www.tug.org/TUGboat/Articles/tb19-2/tb59moore.pdf, at around the 
"Figure 5" area of that reference, Professor Ross Moore explained that the 
problem with the proper positioning of multicharacter subscripts and 
superscripts lies with the browsers (as of at least sometime in May of 2008, 
according to my experience) not yet being facilitated to properly render the 
output in a .html (HyperText Markup Language also referred to herein as 
HTML) file produced by latex2html.

METHOD 1: After considering various solutions to this problem using existing 
browsers, the most convenient one I have found is outlined within 
http://www.cs.tut.fi/~jkorpela/math/ by Jukka K. Korpela. I am grateful for 
that Web site! The approach is to change the HTML code to accommodate the 
use of a subscript and superscript in a way similar to the notation for a 
molecular ion in chemistry. To obtain the superscript and subscript 
vertically aligned above each other, the technique in the Web site I just 
mentioned is to temporarily move the left-hand margin to the left, which in 
turns moves the next-displayed text characters of the subscript to the left 
in such a way as to align them vertically with the superscript characters 
which were entered before the margin was moved to the left. I made some 
slight variations in this approach in two files below, in which I also 
removed some of my ordinary, uninteresting text within the first file 
TestSpanClassIons.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<TITLE>TestSpanClassIons</TITLE>

<html>

<head>

</head>

<LINK REL="STYLESHEET" HREF="TestSpanClassIons.css">

<P>

Okay, here is some text containing <span 
class="ions">23<sup>+50</sup><sub>&minus;35</sub></span>&nbsp;s. At the end 
of this is more text.

</html>

The file TestSpanClassIons.html requires the Cascading-Style-Sheets (.css) 
file TestSpanClassIons.css listed below to work properly:

Contents of the file TestSpanClassIons.css:

ions { line-height: 1.8; }

ions sub { margin-left: -3ex; vertical-align: -0.8ex; }

ions sup { vertical-align: 1.2ex; }

In this way I could obtain for me acceptable displays of the base number 
"23," the superscript "+50", the subscript "-35", with the "+50" nearly over 
the "-35", followed by the unit "s" for seconds in the browsers Internet 
Explorer 7.0.5730.13 (herein referred to as IE7), Mozilla Firefox 2.0.0.14 
(herein referred to as Firefox), and Netscape 8.1 (herein referred to as 
Netscape). I also used for the minus sign "&minus;" instead of the hyphen 
"-" in order to obtain for the minus sign a reasonable length and one close 
to the length of the plus sign in "+50" 
(http://www.alanwood.net/demos/ent4_frame.html). Also I used "&nbsp;" for a 
non-breaking or non-breakable space before the "s" for seconds in order to 
keep the unit "s" from being wrapped around to a new line and therefore 
separated from the numerical data (within 
http://www.myphysicslab.com/web_math.html). In IE7 there was a horizontal 
displacement of the center of "+50" very slightly to the right of the center 
of "-35" when the text size in IE7 was set via "View, "Text Size, Medium" to 
"Medium"; but this relative horizontal displacement seemed to disappear when 
the "Text Size" was instead set to "Larger" or "Smaller". (Unfortunately I 
do not know to what number-point font sizes "Medium", "Larger", and 
"Smaller" correspond.) But one may have to look closely to even notice that 
relative horizontal displacement. In this case the horizontal displacement 
appears to be font-size-related. (There might also be an even smaller 
horizontal in the opposite direction in both the Netscape and Firefox 
browsers; another possibility is that it could have to do with the different 
amount of horizontal space used to display a "0" and "5"; but if such a 
horizontal displacement exists at all, it is so small that I am not certain 
of it and decided not to consider it further.) In 
http://www.cs.tut.fi/~jkorpela/math/ a warning was given about the effect of 
a change in fonts on the relative alignment of the superscript and 
subscript. Also I noticed that the thickness of the displayed type in IE7 
was greater or blacker than in the Firefox and Netscape browsers. It is also 
possible that the left-margin changes might be handled slightly differently 
by the browsers. In any event in the interest of saving further time, for me 
this was an acceptable discrepancy in the vertical alignment of the 
multicharacter superscript and the multicharacter subscript.

METHOD 2: A second approach of my own was far less convenient than the 
method I just discussed for practical use, but produced good, relative, 
vertical alignment. The HTML code was entered into a file I called 
Test.html, which was then opened in various browsers for testing. The 
solution is in the file Test.html below, which worked satisfactorily for 
displaying a multicharacter superscript and a multicharacter subscript along 
with a base number, or in this case

a display at least informationally equivalent to

    +50

23       s

    -35

in the three browsers IE7, Firefox, and Netscape.

Contents of the file Test.html between the pair of long dashed lines:

---------------------------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>

<head>

<title>Test base super sub

</title>

</head>

<table align="left" col="3" cellpadding="0" cellspacing="0">

<tr>

<td rowspan="2" align="right" nowrap="nowrap">

23

</td>

<td rowspan="1" align="left" valign="bottom" nowrap="nowrap">

<span style="font-size:8pt">+50</span>

</td>

<td rowspan="2" align="left" nowrap="nowrap">

<span>&nbsp</span>s

</td >

</tr>

<tr>

<td rowspan="1" align="left" valign="top" nowrap="nowrap">

<span style="font-size:8pt">&#8722</span><span 
style="font-size:8pt">35</span>

</td>

</tr>

</table>

</html>

----------------------------------------------------------------------------------------

Just for the test using the file Test.html, in the final analysis it was not 
necessary to use a Cascading Style Sheet (CSS) in order to have an 
informationally satisfactory display in a browser. The strategy I used for 
making the above display was to make a three-column table in the HTML code 
entered into the file Test.html using a text editor. Depending on the text 
editor used at the time the file was saved on one occasion as a text file 
and on another occasion as a utf8 file, where utf8 is an encoding; but 
keeping it as a text file all the time would probably have been okay. The 
details of the rows of the table were specified within the tags <tr> and 
</tr>, for which "tr" stands for "table row." Then within a row the details 
of a table data (td) cell were specified within the pair of tags <td> and 
</td>. The first column of the table is just one table cell which spans two 
rows with the base number "23" located in the vertically middle, 
horizontally right portion of that table cell. The second column consists of 
two separate rows. I arranged for the superscript "+50" to be placed in the 
bottom, left-hand corner of the table cell in column two, row one of the 
table. I arranged for the subscript "-35" to be placed in the top, left-hand 
corner of the table cell in column two, row two of the table. Then in the 
third column of the table, which like column one spans two rows, I arranged 
for a space and the unit "s" as an abbreviations for seconds to be placed. 
Between a <span> and </span> pair of tags I entered "&nbsp" for a 
non-breaking space to be finally located before the "s" I earlier mentioned 
(http://www.myphysicslab.com/web_math.html). The minus sign in the 
superscript was in the early stages displayed too short compared to the plus 
sign in the subscript; that is it was more like a hyphen than a minus sign 
with a length equal to that of a plus sign. Using a "Courier New" font style 
I was unsuccessful in increasing the length of what I wanted to be the 
length of a minus sign. In attempts to increase the length I tried using 
"&minus" for a minus sign closer in length to the length of the plus sign. 
This worked okay in the browsers Mozilla Firefox 2.0.0.14 and Netscape 8.1, 
but not in Internet Explorer 7.0.5730.13 in displaying at least one of 
Test.html or the .html file produced by latex2html which included some HTML 
lines of code similar to those in Test.html; in Internet Explorer 
7.0.5730.13 "&minus35" was instead actually displayed in the failed case (I 
wonder if the result would have been successful if I had instead used 
"&minus;" with a semicolon following "&minus".). But fortunately 
substituting the decimal numeric equivalent of "&minus," or "&#8722", 
allowed the subscript "-35" to be properly displayed in the 
Internet-Explorer-7.0.5730.13, Mozilla-Firefox-2.0.0.14, and Netscape-8.1 
browsers. To allow the superscript "+50" and the subscript "-35" to have 
smaller sizes than the base number "23," for only the superscript and 
subscript the font size was locally changed to an eight-point font using the 
"style" option of the tag <span>.

Then I took the contents of Test.html after its first line <!DOCTYPE HTML 
PUBLIC "-//W3C//DTD HTML 4.01//EN"> and copied and pasted them into a file 
of the form MyLaTeXFile.html produced after executing the following two 
commands on a .tex file of the form MyLaTeXFile.tex:

latex MyLaTeXFile.tex

latex2html -nonavigation -no_math -html_version 4.01,math -split 0 
MyLaTeXFile.tex

using version latex2html 2002-2-1 (1.70) and, if I remember correctly, 
version LaTeX2e of latex. The output file, produced by executing latex2html, 
of the form MyLaTeXFile.html had as its top line the line:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

which was, of course produced by latex2html; and note that "HTML 4.0 
Transitional" instead of "HTML 4.01" appears in the above "!DOCTYPE" line. 
In a "versions" folder of my latex2html 2002-2-1 installation I found the 
file html_4_01.pl which contains a line which contains "Language definitions 
for HTML 4.01." However, due to a message which appeared during the 
processing by latex2html 2002-2-1 of my file of the form MyLaTeXFile.tex, it 
is clear that the file html4_0.pl was instead loaded. This is consistent 
with a note I found within the file latex2html (version 2002-2-1 of it) 
stating, in effect, that only up through HTML 4.0 had been implemented 
within in it; so I suppose the file html_401.pl in the "versions" folder is 
there for use in a potential later version of latex2html expected to fully 
implement HTML 4.01. Although I am not one of the developers of code for 
latex2html, unless the November, 2002 version of latex2html fully implements 
HTML 4.01, something I do not know, perhaps other people might fully 
implement HTML 4.01 in a future version of latex2html.

The displayed result in the three Web browsers after inputting the lines of 
code following the first line in Test.html above into a file of the form 
MyLaTeXFile.html produced by latex2html 2002-2-1 was slightly better than 
the displayed result for Test.html! Imagine a baseline drawn horizontally 
through the bottom of the base number "23." In the display of Test.html in 
the three browsers that imaginary line passed slightly above the whole 
subscript "-35." But in displaying the file of the form MyLaTeXFile.html 
that imaginary line passed through the upper part of the subscript, relative 
placement I prefer. So there must be some additional latex2html-produced 
code in one or both of the files of the form MyLaTeXFile.html and/or 
MyLaTeXFile.css which improved that relative placement.

A minor nuance was that in Internet Explorer 7.0.5730.13 the base number 
"23" and "s" were of slightly thicker "type" than for the smaller 
superscript "+50" and subscript "-35"; on the other hand, in both the 
Mozilla-Firefox-2.0.0.14 and Netscape-8.1 browsers the thickness of the type 
for all of the base number, superscript, and subscript appeared to be 
uniformly the same.

In the general situation to accommodate the use of this method within real 
sentences it is necessary to add some text before the base number, for 
example, "The half-life was 23" to replace "23" and then following the unit 
"s" to have, say "s. This was the result obtained. Then there could be more 
text here." To keep from having lots of empty space in one or more lines or 
else too long a line of text containing a table of the form I have been 
discussing, it would be good to format the whole paragraph containing such a 
superscript-subscript-base-number combination with <LB> for Line Break or 
<BR> for BReak after a desired number of characters per line. Even so there 
is a minor undesirable effect with this method in that the Firefox and 
Netscape browsers placed a blank space at the beginning of the line 
containing the table, whereas IE7 did not. There is also a future potential 
problem with method 2 in that <table align="left"> has been deprecated 
(http://www.htmlcode.tutorial.com/help/sutra28942,html), which according to 
http://answers.yahoo.com/question/index?qid=20071229144030AApZqWi means that 
the "table" attribute align="left" is still supported in apparently HTML 
4.01, but is on its way to becoming obsolete in some future version of XHTML 
or HTML (perhaps in XHTML, eXtensible HTML). Also there should be a <BR/> 
placed in an HTML file using <BR> in order to be compatible with XHTML in 
the future (http://www.w3schools.com/html/hhtml_primary.asp).

----

In spite of the sometimes better alignment that may have been achieved using 
method 2 compared to using method 1, for practical use I decided to use 
method 1 for its brevity, especially since it does not require setting the 
line lengths for a paragraph containing the base number, multicharacter 
superscript, multicharacter subscript, and following unit. I learned in the 
course of my Internet study that HyperText Markup Language is not a computer 
language like C++ or FORTRAN, but rather a system 
(http://webmaster.com/webpage.htm) of terms which people have apparently 
accepted as having specific meanings for the display of a Web page. It 
appears that people with an understanding of the agreed meanings of those 
terms have designed Web-browser software to implement those meanings in the 
displays of things on Web pages. Thus there is apparently no HTML code per 
se to be found for an HTML tag like, for example <SPAN>. Rather browser 
programs on reading such an instruction apparently have been written by 
human beings to implement the instruction <SPAN> according to the meaning of 
it agreed to by human beings.

I can imagine another general way to achieve the goal of obtaining good 
relative placement for a base number, supercript, and subscript, even though 
I haven't tried all parts of the following thinking. For example, one could 
first print on paper the relative arrangement of the base, superscript, and 
subscript one wants. This could be done by after executing a command of the 
form "latex MyLaTeXFile.tex" to print the resulting file with a name of the 
form "MyLaTeXFile.dvi"; or in a different and text file one could use a text 
editor which allows superscripts and subscripts to produce the relative 
arrangement one desires. Either way one could then scan the printed output 
on paper to make a scanned image file of it; using appropriate converter 
software then one could hopefully convert that image to one latex2html could 
be used to conveniently handle as a figure, such as one contained in an 
Encapsulated Post Script (.eps) or Portable Network Graphics (.png) file. 
Except for the equation number this could work for such an arrangement set 
outside of lines of text like an equation would be. Since making in-line 
mathematical expressions and portions of equations as .png figures is how I 
have used a latex2html command, it ought to be possible to make .png, 
in-line images from originally scanned files after their conversion to .png 
images. This assumes that (a) converter program(s) exist(s) to convert the 
scanned image file into a .png file, even if this has to be done in two 
steps with two different computer programs.

I should mention that I also pursued a third method of using <table 
class="fraction"...> using a transparent fraction line. This worked 
satisfactorily to display the base number in place of something like "x=", 
the superscript in place of the numerator of the fraction, and the subscript 
in place of the denominator of the fraction. But I had difficulty obtaining 
the proper placement of the subsequent unit, for example "s" on the baseline 
of the base number, which in the example here is "23". Had I pursued that 
method further, perhaps there may have been problems conveniently placing 
the whole thing within a paragraph which might have required special 
attention to line lengths in the containing paragraph, similar to using 
<table> without using the "fraction" attribute.

I also attempted to solve the relative placement problem using Javascript 
code. But the successive use of subscript and superscript commands resulted 
in a horizontal separation of the displayed superscript and subscript, 
rather than having them one over the other as I desired. Aside from the 
prior thinking in these last three paragraphs, I am grateful for help to 
have found a couple of methods which worked satisfactorily for me with 
method 1 I expect to be the one of the two requiring the smaller amount of 
time for practical use.

Pat


Internet references, to some of which I did not explicitly refer in the 
above text:

1. http://www.tug.org/TUGboat/Articles/tb19-2/tb59moore.pdf

2. http://www.myphysicslab.com/web_math.html

3. http://www.htmlhelp.com/references/css/quick-tutorial.html

4. http://www.htmlhelp.com/references/css/style-html.html

5. http://www.webmasterworld.com/forum/12375.html

6. 
http://htmlhelp.com/references/html/tutorials/html_401/article.php/3479661

7. 
http://htmlhelp.com/references/html/tutorials/html40/entities/symbols.html

8. http://htmlhelp.com/references/html/tutorials/html40/tables/

9. http://htmlhelp.com/references/html/tutorials/html40/special/font.html

10. 
http://www.sfr-fresh.com/unix/www/latex2html-2002-2-1.tar.gz:a/latex2html-2002-2-1/versions/html4_1

11. http://www.alanwood.net/demos/ent4_frame.html

12. http://www.cs.tut.fi/~jkorpela/math/index.html

13. http://www.w3schools.com/html/hhtml_primary.asp

14. http://www.htmlcode.tutorial.com/help/sutra28942,html

15. http://answers.yahoo.com/question/index?qid=20071229144030AApZqWi

----- Original Message ----- 
From: "Lawrence Patrick Somerville" <L_Pat_S at hotmail.com>
To: <latex2html at tug.org>
Sent: Thursday, May 15, 2008 3:10 AM
Subject: [l2h] Using a multiple-character superscript and 
amultiple-character subscript at the same time with anundesired horizontal 
displacement between them instead ofabove and below each other


> Hi.  I am using latex2html version 2002-2-1 (also called version 1.70). 
> I
> tried something similar to these examples of LaTeX commands in a .tex, 
> LaTeX
> file:
>
> $23_{-35}^{+50}$s
>
> \begin{equation}
> \[ 23_{-35}^{+50}s\]    (or perhaps \[23_{-35}^{+50}\]s )
> \end{equation}
>
> \begin{equation}
> 23_{-35}^{+50}s
> \end{equation}
>
>  The result for something similar to probably one of the above, middle
> examples looked okay with the equivalent of the "+50" right above the 
> "-35"
> in the .dvi file of the form MyLaTeXFile.dvi generated by a command of the
> form ''latex MyLaTeXFile.tex" when viewed with the  KDVI-Viewer program.
>
> But after generating a file with a name of the form MyLaTeXFile.html with 
> a
> command of the form
>
> latex2html -nonavigation -no_math -html_version 3.2,math -split 0
> MyLaTeXFile.tex
>
> with a different, .tex file name than MyLaTeXFile.tex, I viewed the file
> with the name of the form MyLaTeXFile.html in four Web browsers: Netscape
> 8.1, Internet Explorer 7.0.5730.13, Mozilla Firefox 2.0.0.14, and I think 
> a
> much older version of the Firefox browser; regarding the horizontal
> alignment with the .html file the result was always something similar to 
> the
> following:
>
>          +50
> 23            s
>    -35
>
> (In the above example pay little attention to the vertical alignment and a
> lot of attention to the relative horizontal alignment.  In my example 
> above
> I know that the vertical spacings between the superscript "+50" and base
> number "23" and between the subscript "-35" and base number "23" are too
> large.).   That is there was an undesired horizontal displacement between
> the "-35" and the "+50" rather than having these sets of characters
> vertically aligned one right above the other as I wanted.  Note that both
> the superscript and subscript in this example consist of multiple 
> characters
> with the necessity that each of these two sets of characters be enclosed
> within a pair of braces, as in {-35}.  Such a horizontal displacement was
> observed in all four browsers using one of the middle examples.  It was 
> also
> observed with the first, one of the second, and the third above examples 
> of
> LaTeX command sequences in the old Firefox or Konqueror browsers, 
> depending
> on which browser I was using at the time of the test of three of the 
> above,
> four, LaTeX command sequences.  The above horizontal displacement is 
> rather
> what I would expect with a different command of something like
> $23_{-35}{}^{+50}$s in which I understand the {} is supposed to introduce
> such a horizontal displacement between in this example the "-35" and the
> "+50."  What LaTeX command do I need to type, including a possible
> "workaround" solution, in order to have the superscript and subscript in
> line right above each other, more like this (Again pay little attention to
> the vertical alignment and a lot of attention to the relative horizontal
> alignment I desire.):
>
>    +50
> 23      s
>    -35
>
> ?  Is it necessary to change the font size of and/or use the "\mbox" 
> command
> on the characters in the superscript and subscript in order to avoid a
> vertical "collision" between the characters in the superscript and
> subscript?  Or must I type a different latex2html command than I used 
> above
> in order to achieve the horizontal alignment I desire?  Or must a new
> version of latex2html be used and/or made to fix this problem?  In nuclear
> science this sort of thing is useful in citing half-lives with asymmetric
> error limits as in the above example, but with probably one more space
> before the "s" for "seconds," and in symbols for nuclear isotopes like
>
> 130
>      Ba
>  56
>
> when one wants to display both the atomic number, which in this case is 56
> for the element barium with the chemical symbol "Ba," and the mass number 
> or
> number of neutrons and protons, which in this case is 130, of an isotope.
> Thanks in advance for your help.
>
> Pat
>
> _______________________________________________
> latex2html mailing list
> latex2html at tug.org
> http://tug.org/mailman/listinfo/latex2html
> 



More information about the latex2html mailing list