mmultiscripts: alignment of scripts preceding a character

74 views
Skip to first unread message

Alexander Krutik

unread,
Aug 20, 2012, 9:50:42 AM8/20/12
to mathja...@googlegroups.com
Hello MathJax Users,

I have a question regarding alignment of scripts in mmultiscripts. In the code below scripts preceding a character are left justified.
<math>
<mrow>
  <mmultiscripts>
    <mo> O </mo>
    <mprescripts/>
    <mn> 18 </mn>
      <mn> 1 </mn>
  </mmultiscripts>
</mrow>
</math>

First of all, Is it an issue in MathJax? I looked into MathML specification (http://www.w3.org/TR/MathML3/chapter3.html#presm.mmultiscripts), but didn't find a clear answer there. MathType right justifies such scripts. Can someone suggest an elegant workaround to right justify scripts preceding a character? I've tried to play with direction of text (LTR/RTL), but this didn't help. Of course one can add spaces, but this does not seem to be an elegant solution.

Thanks,
Alex

David Carlisle

unread,
Aug 20, 2012, 10:06:19 AM8/20/12
to mathja...@googlegroups.com
That's an interesting question. Perhaps you should raise it on
www-math as a potential bug report on the spec in that it ought to
make it clear. When I've implemented mapping mprescripts to TeX it has
always ended up looking like \specialstrut_a^b{base} where
\specialstrut is an invisible rule the height and depth of base, so
the prescripts are always left aligned. As you note the spec just says
"vertically-aligned pairs" which could be clearer.....

David Carlisle

unread,
Aug 20, 2012, 10:13:15 AM8/20/12
to mathja...@googlegroups.com
I've raised this on the internal math working group list as a possible
issue requiring clarification.

Davide P. Cervone

unread,
Aug 20, 2012, 10:17:45 AM8/20/12
to mathja...@googlegroups.com
You are correct that MathJax left-justifies all scripts, including pre-scripts, and that the spec doesn't indicate how these should be justified.  I will await David Carlisle's update before deciding how to handle the issue in general.

In the meantime, you can use something like

<math>
<mrow> <mmultiscripts> <mo> O </mo> <mprescripts/> <mn> 18 </mn> <mrow> <mphantom><mn> 8 </mn></mphantom> <mn> 1 </mn> </mrow> </mmultiscripts> </mrow> </math>

to get the scripts to align the way you want (ugly, but works).  Note that the numbers are all the same width (in the MathJax fonts), so you can do this even if the numbers are not the same in both scripts.

An alternative is to use an <mphantom> that contains the wider of the two, and <mpadded> to shift the other one backwards.

<mrow> <mmultiscripts> <mo> O </mo> <mprescripts/> <mn> 18 </mn> <mrow> <mphantom><mn> 18 </mn></mphantom> <mpadded width="0px" lspace="-1width"> <mn> 1 </mn> </mpadded> </mrow> </mmultiscripts> </mrow> </math>

This is the most general way, and doesn't rely on characters being the same width.  It is a bit awkward, but it works.

Davide

Davide P. Cervone

unread,
Aug 20, 2012, 10:19:34 AM8/20/12
to mathja...@googlegroups.com
Thanks for checking into this, David. I look forward to hearing the
results of your deliberations. I suspect that right-justification is
probably the better choice, at least if there is only one pre-script
in each position (sup and sub). What I wonder about is how to handle
multiple prescripts. But how often does that occur?

Davide

Alexander Krutik

unread,
Aug 20, 2012, 10:48:08 AM8/20/12
to mathja...@googlegroups.com
Thank you David and Davide!

Davide, I will use your second suggestion. This is a very elegant workaround.

Alex

Frédéric WANG

unread,
Aug 20, 2012, 1:04:06 PM8/20/12
to mathja...@googlegroups.com, www-...@w3.org
Firefox vertically aligns sup/sub scripts with respect to their centers,
but there is no comment in the source explaining this choice. Scripts of
msubsup are aligned left, though.
--
Fr�d�ric Wang
maths-informatique-jeux.com/blog/frederic

David Carlisle

unread,
Aug 21, 2012, 7:55:13 PM8/21/12
to mathja...@googlegroups.com
On 20 August 2012 14:50, Alexander Krutik <krutik.a...@gmail.com> wrote:
I put some thoughts and a test file on the public mathml list at

http://lists.w3.org/Archives/Public/www-math/2012Aug/0006.html

David

Davide P. Cervone

unread,
Aug 21, 2012, 8:04:56 PM8/21/12
to mathja...@googlegroups.com
Thanks, David, that's an excellent summary. As always, your advice,
interest, and efforts are much appreciated.

Davide
Reply all
Reply to author
Forward
0 new messages