Discussion:
Space between identifiers in MathML
(too old to reply)
b***@yahoo.com
2005-01-21 15:40:44 UTC
Permalink
Hi,

I hope that someone can help me with the following MathML problem. When
I markup product terms like "xy", I normally use something like:

<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>y</mi>
</mrow>

However, when this is displayed, there is whitespace between the "x"
and the "y" which doesn't look quite right. Quite by accident, I
discovered that if I replace <mrow> with <mfenced>, the extra
whitespace disappears and all is well:

<mfenced open="" close="" separators="">
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>y</mi>
</mfenced>

See the attached files for an example of this. Open qq_4.xul in
Mozilla. The first equation uses <mrow>, the second uses <mfenced>.

Is this a bug in the implementation of MathML? I was under the
impression that the lspace and rspace attributes were automatically set
at the appropriate values using the operator dictionary, etc. Is the
<mrow> specification above the correct was of specifying product terms?


Any help would be appreciated!

Brendan


=======================================================================
qq_4.xul
=======================================================================

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="paperviewer.css"?>
<?xml-stylesheet type="text/css" href="math.css"?>
<?xml-stylesheet type="text/css" href="resource://gre/res/mathml.css"?>

<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"

xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:math="http://www.w3.org/1998/Math/MathML">

<script src="chrome://global/content/dialogOverlay.js"
type="application/x-javascript"/>

<vbox class="vbox-micro">

<description class="d-micro">
<math display="block" class="micro"
xmlns="http://www.w3.org/1998/Math/MathML">
<mtable>
<mtr>
<mtd class="lhs">
<mi>x</mi>
<mo>=</mo>
<mrow>
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd class="lhs">
<mi>x</mi>
<mo>=</mo>
<mfenced open="" close="" separators="">
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</mfenced>
</mtd>
</mtr>
</mtable>
</math>
</description>
</vbox>

</window>

=======================================================================
paperviewer.css
=======================================================================

window {background-color : gainsboro; font-size : 12pt; font-family :
"Times New Roman"; color : black; -moz-box-orient : vertical; }

.vbox-micro {
border-width : 1px;
border-style : outset;
border-color : brown;
padding : 2px;
margin : 2px;
background-color : white;
-moz-border-radius : 8px;
overflow : auto;
-moz-box-flex : 1;
}

=======================================================================
math.css
=======================================================================

math { font-family : "Times New Roman";}

math[display="block"][class="micro"] {
border : 1px ;
border-style : outset ;
border-color : transparent ;
-moz-border-radius : 8px ;
background-color : whitesmoke ;
margin-left : 0px ;
margin-right : 0px ;
margin-top : 5px ;
margin-bottom : 5px ;
color : blue ;
padding : 2px ;
}

math[display="block"][class="micro"]:hover {
border-color : darkblue; background-color : ivory;
}

mtd[class="lhs"] {text-align : right;}
mtd[class="rhs"] {text-align : left;}
Roger B. Sidje
2005-01-21 20:43:28 UTC
Permalink
Initially, the MathML engine was doing what you are suggesting.
But &InvisibleTimes; has lspace=0 and rspace=0 in the Operator
Dictionary. Therefore, it didn't take for a bug to find its way in
bugzilla saying that "<mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi>" and
other invisible operators have no inter-space. That is, precisely the
opposite of what you are asking... I since changed the code to add that
inter-space. So, whichever way you turn, the default behavior is going
to look as a bug for somebody.

The default looks much nicer in the mix of lots of text that are fitting
to get attention on a web page. But I agree that it might look a bit
funny in a XUL button, or some such, in the XUL stuff that are doing.

So, here is nice workaround. Double it to say that it isn't the default
&InvisibleTimes;

<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;&InvisibleTimes;</mo>
<mi>y</mi>
</mrow>

Much simpler than <mfenced> and handy to add/remove at special spots to
tune your XUL appearance. Due to its other roles, <mfenced> uses a
different code-path than doesn't receive any inter-space (as yet).
---
RBS
Post by b***@yahoo.com
Hi,
I hope that someone can help me with the following MathML problem. When
<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>y</mi>
</mrow>
However, when this is displayed, there is whitespace between the "x"
and the "y" which doesn't look quite right. Quite by accident, I
discovered that if I replace <mrow> with <mfenced>, the extra
<mfenced open="" close="" separators="">
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>y</mi>
</mfenced>
See the attached files for an example of this. Open qq_4.xul in
Mozilla. The first equation uses <mrow>, the second uses <mfenced>.
Is this a bug in the implementation of MathML? I was under the
impression that the lspace and rspace attributes were automatically set
at the appropriate values using the operator dictionary, etc. Is the
<mrow> specification above the correct was of specifying product terms?
Any help would be appreciated!
Brendan
=======================================================================
qq_4.xul
=======================================================================
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="paperviewer.css"?>
<?xml-stylesheet type="text/css" href="math.css"?>
<?xml-stylesheet type="text/css" href="resource://gre/res/mathml.css"?>
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:math="http://www.w3.org/1998/Math/MathML">
<script src="chrome://global/content/dialogOverlay.js"
type="application/x-javascript"/>
<vbox class="vbox-micro">
<description class="d-micro">
<math display="block" class="micro"
xmlns="http://www.w3.org/1998/Math/MathML">
<mtable>
<mtr>
<mtd class="lhs">
<mi>x</mi>
<mo>=</mo>
<mrow>
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd class="lhs">
<mi>x</mi>
<mo>=</mo>
<mfenced open="" close="" separators="">
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</mfenced>
</mtd>
</mtr>
</mtable>
</math>
</description>
</vbox>
</window>
=======================================================================
paperviewer.css
=======================================================================
"Times New Roman"; color : black; -moz-box-orient : vertical; }
.vbox-micro {
border-width : 1px;
border-style : outset;
border-color : brown;
padding : 2px;
margin : 2px;
background-color : white;
-moz-border-radius : 8px;
overflow : auto;
-moz-box-flex : 1;
}
=======================================================================
math.css
=======================================================================
math { font-family : "Times New Roman";}
math[display="block"][class="micro"] {
border : 1px ;
border-style : outset ;
border-color : transparent ;
-moz-border-radius : 8px ;
background-color : whitesmoke ;
margin-left : 0px ;
margin-right : 0px ;
margin-top : 5px ;
margin-bottom : 5px ;
color : blue ;
padding : 2px ;
}
math[display="block"][class="micro"]:hover {
border-color : darkblue; background-color : ivory;
}
mtd[class="lhs"] {text-align : right;}
mtd[class="rhs"] {text-align : left;}
_______________________________________________
Mozilla-mathml mailing list
http://mail.mozilla.org/listinfo/mozilla-mathml
b***@yahoo.com
2005-01-22 23:11:16 UTC
Permalink
Hi Roger,

Thanks for the reply. I would have thought that setting lspace=0 and
rspace=0 for the InvisibleTimes operator was the *correct* thing to do!
If someone wants space between identifiers, then it's probably more
appropriate to use the "mspace" tag, or to set the lspace and rspace
explicitly or to control the spacing either through stylesheets or the
"mstyle" tag. Zero lspace and zero rspace are a good set of defaults
for something that is invisible! Also, I think that most Maths books
would typeset product terms like "xy" without any interidentifier space
most of the time, so this should probably be the default behaiour.

The other thing to consider is that we should see the same output using
the "mfenced" tag (with open="" close="" and separators="") since (in
my opinion!) the "mfenced" tag is similar to the "mrow" tag but with
more functionality.

Thanks a million for the workaround! I hope that you don't mind me
saying that it seems to be a bit non-intuitive, i.e. one
&InvisibleTimes; gives non-zero space but two consecutive
&InvisibleTimes; gives zero space.

Thanks again for you help -

Best Regards,

Brendan
Post by Roger B. Sidje
Initially, the MathML engine was doing what you are suggesting.
But &InvisibleTimes; has lspace=0 and rspace=0 in the Operator
Dictionary. Therefore, it didn't take for a bug to find its way in
bugzilla saying that "<mi>x</mi><mo>&InvisibleTimes;</mo><mi>y</mi>" and
other invisible operators have no inter-space. That is, precisely the
opposite of what you are asking... I since changed the code to add that
inter-space. So, whichever way you turn, the default behavior is going
to look as a bug for somebody.
The default looks much nicer in the mix of lots of text that are fitting
to get attention on a web page. But I agree that it might look a bit
funny in a XUL button, or some such, in the XUL stuff that are doing.
So, here is nice workaround. Double it to say that it isn't the default
&InvisibleTimes;
<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;&InvisibleTimes;</mo>
<mi>y</mi>
</mrow>
Much simpler than <mfenced> and handy to add/remove at special spots to
tune your XUL appearance. Due to its other roles, <mfenced> uses a
different code-path than doesn't receive any inter-space (as yet).
---
RBS
Post by b***@yahoo.com
Hi,
I hope that someone can help me with the following MathML problem. When
<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>y</mi>
</mrow>
However, when this is displayed, there is whitespace between the "x"
and the "y" which doesn't look quite right. Quite by accident, I
discovered that if I replace <mrow> with <mfenced>, the extra
<mfenced open="" close="" separators="">
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>y</mi>
</mfenced>
See the attached files for an example of this. Open qq_4.xul in
Mozilla. The first equation uses <mrow>, the second uses <mfenced>.
Is this a bug in the implementation of MathML? I was under the
impression that the lspace and rspace attributes were automatically set
at the appropriate values using the operator dictionary, etc. Is the
<mrow> specification above the correct was of specifying product terms?
Any help would be appreciated!
Brendan
=======================================================================
Post by Roger B. Sidje
Post by b***@yahoo.com
qq_4.xul
=======================================================================
Post by Roger B. Sidje
Post by b***@yahoo.com
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="paperviewer.css"?>
<?xml-stylesheet type="text/css" href="math.css"?>
<?xml-stylesheet type="text/css"
href="resource://gre/res/mathml.css"?>
Post by Roger B. Sidje
Post by b***@yahoo.com
<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
Post by Roger B. Sidje
Post by b***@yahoo.com
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:math="http://www.w3.org/1998/Math/MathML">
<script src="chrome://global/content/dialogOverlay.js"
type="application/x-javascript"/>
<vbox class="vbox-micro">
<description class="d-micro">
<math display="block" class="micro"
xmlns="http://www.w3.org/1998/Math/MathML">
<mtable>
<mtr>
<mtd class="lhs">
<mi>x</mi>
<mo>=</mo>
<mrow>
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd class="lhs">
<mi>x</mi>
<mo>=</mo>
<mfenced open="" close="" separators="">
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</mfenced>
</mtd>
</mtr>
</mtable>
</math>
</description>
</vbox>
</window>
=======================================================================
Post by Roger B. Sidje
Post by b***@yahoo.com
paperviewer.css
=======================================================================
Post by Roger B. Sidje
Post by b***@yahoo.com
"Times New Roman"; color : black; -moz-box-orient : vertical; }
.vbox-micro {
border-width : 1px;
border-style : outset;
border-color : brown;
padding : 2px;
margin : 2px;
background-color : white;
-moz-border-radius : 8px;
overflow : auto;
-moz-box-flex : 1;
}
=======================================================================
Post by Roger B. Sidje
Post by b***@yahoo.com
math.css
=======================================================================
Post by Roger B. Sidje
Post by b***@yahoo.com
math { font-family : "Times New Roman";}
math[display="block"][class="micro"] {
border : 1px ;
border-style : outset ;
border-color : transparent ;
-moz-border-radius : 8px ;
background-color : whitesmoke ;
margin-left : 0px ;
margin-right : 0px ;
margin-top : 5px ;
margin-bottom : 5px ;
color : blue ;
padding : 2px ;
}
math[display="block"][class="micro"]:hover {
border-color : darkblue; background-color : ivory;
}
mtd[class="lhs"] {text-align : right;}
mtd[class="rhs"] {text-align : left;}
_______________________________________________
Mozilla-mathml mailing list
http://mail.mozilla.org/listinfo/mozilla-mathml
Roger B. Sidje
2005-01-24 09:35:13 UTC
Permalink
Post by b***@yahoo.com
Hi Roger,
Thanks for the reply. I would have thought that setting lspace=0 and
rspace=0 for the InvisibleTimes operator was the *correct* thing to do!
It is a little bit more involved than you would think at first. Consider:

<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>sin</mi>
<mo>&ApplyFunction;</mo>
<mi>x</mi>
</mrow>

Do you really want to see: xsinx ?!? (change also 'sin x' to 'f(x)')

It is far less ambiguous and more readable to show: x sin x
(with the actual inter-space thinner than this whitespace here.)

I can then imagine your next idea: if it is this or that, then no
inter-space or such amount of inter-space. Which is what I said at the
opening: that it is a bit more involved on further thoughts, especially
considering that things may be buried deep inside a XML tree, and
you can have <mi fontstyle="italic">sin</mi>. You get the picture.

That's why there is that default inter-space -- it isn't always added to
be precise (it is context sensitive). Of course, there is still room for
improvement in the current algorithm, as usual.
Post by b***@yahoo.com
If someone wants space between identifiers, then it's probably more
appropriate to use the "mspace" tag, or to set the lspace and rspace
explicitly or to control the spacing either through stylesheets or the
"mstyle" tag. Zero lspace and zero rspace are a good set of defaults
for something that is invisible! Also, I think that most Maths books
would typeset product terms like "xy" without any interidentifier space
most of the time, so this should probably be the default behaiour.
On the screen, it has been my observation that a little bit of space is
safer than no space at all. That's why the default behaviour does that.
But I have never considered the current behaviour as the end of the
story myself. I still think it can be improved.
Post by b***@yahoo.com
The other thing to consider is that we should see the same output using
the "mfenced" tag (with open="" close="" and separators="") since (in
my opinion!) the "mfenced" tag is similar to the "mrow" tag but with
more functionality.
Sure. That would be preferable.
Post by b***@yahoo.com
Thanks a million for the workaround! I hope that you don't mind me
saying that it seems to be a bit non-intuitive, i.e. one
&InvisibleTimes; gives non-zero space but two consecutive
&InvisibleTimes; gives zero space.
It works because they are seen internally as two different operators,
which they are. One isn't in the Operator Dictionary, the other is and
is treated specially to have a much requested inter-space. Didn't we
agree that the other was a _work-around_? To make you happier: you can
just define an internal entity, say &InvisibleProduct;, that maps to the
double &InvisibleTimes; and can be used in the content to hide the thing
away from your sight...
---
RBS
Bruce Miller
2005-06-10 19:46:42 UTC
Permalink
Sorry I stumbled onto this so late, but...
Post by b***@yahoo.com
Post by b***@yahoo.com
Hi Roger,
Thanks for the reply. I would have thought that setting lspace=0 and
rspace=0 for the InvisibleTimes operator was the *correct* thing to do!
<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>sin</mi>
<mo>&ApplyFunction;</mo>
<mi>x</mi>
</mrow>
Do you really want to see: xsinx ?!? (change also 'sin x' to 'f(x)')
It is far less ambiguous and more readable to show: x sin x
(with the actual inter-space thinner than this whitespace here.)
On linux it isn't thinner, and in that case, I _would_ prefer the former! :>

As for "less ambiguous", the obvious markup for something like
F(x)=ab
ends up looking like:
F (x)=a b

I'm not sure what platform the OP was using; but I guess your
analysis of the problem _was_ relevant to the him, since on Linux,
the suggested workaround (doubling the entity) just doubles the
amount of space!

This suggests that the "bug" is more related to the mis-display
of the &ApplyFunction; or &InvisibleTimes; glyph itself, rather
than spacing around the operator.

There are a few long-standing bug on XFT based linux builds
that apparently relate to this issue
https://bugzilla.mozilla.org/show_bug.cgi?id=237152
https://bugzilla.mozilla.org/show_bug.cgi?id=284815
https://bugzilla.mozilla.org/show_bug.cgi?id=205387

I certainly appreciate the work you've put into Mozilla's MathML,
and it's sooo close to gorgeous, but I'd hate for these to be forgotten....

bruce miller
Roger B. Sidje
2005-06-11 12:12:50 UTC
Permalink
Post by Bruce Miller
Sorry I stumbled onto this so late, but...
Post by b***@yahoo.com
Post by b***@yahoo.com
Hi Roger,
Thanks for the reply. I would have thought that setting lspace=0 and
rspace=0 for the InvisibleTimes operator was the *correct* thing to do!
<mrow>
<mi>x</mi>
<mo>&InvisibleTimes;</mo>
<mi>sin</mi>
<mo>&ApplyFunction;</mo>
<mi>x</mi>
</mrow>
Do you really want to see: xsinx ?!? (change also 'sin x' to 'f(x)')
It is far less ambiguous and more readable to show: x sin x
(with the actual inter-space thinner than this whitespace here.)
On linux it isn't thinner, and in that case, I _would_ prefer the former! :>
As for "less ambiguous", the obvious markup for something like
F(x)=ab
F (x)=a b
I'm not sure what platform the OP was using; but I guess your
analysis of the problem _was_ relevant to the him, since on Linux,
the suggested workaround (doubling the entity) just doubles the
amount of space!
This suggests that the "bug" is more related to the mis-display
of the &ApplyFunction; or &InvisibleTimes; glyph itself, rather
than spacing around the operator.
What you describe looks like the first bug on your list - 237152.
A possible way to fix that: just don't render... i.e., filter
&ApplyFunction; and &InvisibleTimes; out so that the font subsystem
don't get hold of them. This way, it won't have the risk of selecting
those strange glyphs that some users are seeing. BTW, this is what is
advocated in the last bug on your list -- 205387. Rather than waiting
for that bug, I should perhaps just add a simple work-around in the
MathML code to special case &ApplyFunction; and &InvisibleTimes;.
---
RBS
Post by Bruce Miller
There are a few long-standing bug on XFT based linux builds
that apparently relate to this issue
https://bugzilla.mozilla.org/show_bug.cgi?id=237152
https://bugzilla.mozilla.org/show_bug.cgi?id=284815
https://bugzilla.mozilla.org/show_bug.cgi?id=205387
I certainly appreciate the work you've put into Mozilla's MathML,
and it's sooo close to gorgeous, but I'd hate for these to be forgotten....
bruce miller
_______________________________________________
Mozilla-mathml mailing list
http://mail.mozilla.org/listinfo/mozilla-mathml
Loading...