Re: Formula alignment

Neil Soiffer <[email protected]> Fri, 18 Dec 2015 17:30:09 -0800
Newsgroups gmane.comp.web.mathematics
Message-ID <CAESRWkCQ7vVc5CpcgA5HH3nDbLqjtOUVMPwSkxmEiv5hNaO7Ow@mail.gmail.com>
--047d7b45070e55ab7805273632ea
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

David's solution is widely used and is what people do in TeX. You do need
add some spacing around the '=3D' though (probably by overriding
columnspacing).

Another option that is widely supported in renderers is to use <mphantom>
to get alignment. That's pretty hacky though.

There are also options to use with indenttarget, although that still isn't
well implemented even though it isn't that hard to implement. It works well
if the first equation is the left of the second. I.e., if you had
x+1=3Dy
    y=3Dx+1

because you can put the target on the '1'.

Perhaps in MathML 4 we could add a variant of indenting so that all marked
characters align (only the first on a line -- that would handle the common
cases and avoid the complications with maligngroup/malignmark that have
caused others to put off implementing maligngroup/malignmark.

Neil Soiffer
Senior Scientist
Design Science, Inc.
www.dessci.com
~ Makers of MathType, MathFlow, MathPlayer, MathDaisy, Equation Editor ~


On Fri, Dec 18, 2015 at 9:20 AM, David Carlisle <[email protected]> wrote:

> On 18/12/2015 16:56, Daniel Marques wrote:
>
>> Dear MathML group,
>>
>> I=E2=80=99m just wandering how to align formulas given a symbol. For exa=
mple,
>>
>> __y=3Dx+1
>>
>> x+1=3Dy
>>
>> (where the _ are spaces)
>>
>> Reading the MathML specification, I came up with
>>
>> <mtable>
>>
>>    <mtd>
>>
>>      <mi>y</mi>
>>
>>      <malignmark/>
>>
>>      <mo> =3D </mo>
>>
>>     <mi>x</mi>
>>
>>      <mo>+</mo>
>>
>>      <mn>1</mn>
>>
>>    </mtd>
>>
>>   <mtd>
>>
>>      <mi>x</mi>
>>
>>      <mo>+</mo>
>>
>>      <mn>1</mn>
>>
>>      <malignmark/>
>>
>>      <mo> =3D </mo>
>>
>>      <mi>y</mi>
>>
>>    </mtd>
>>
>> </mtable>
>>
>> Do you think that this is the best way to express that?
>>
>
> Apart from a missing mtr (was optional in mathml 1 but not since)
> yes but.....
>
>
> malignmark is one of the trickier areas of mathml and not supported
> in all mathml renderers so if you are targetting a specific system and
> it works then fine, otherwise I'd split it as two columns right aligned
> for the left hand side and left aligned for the rest. Of course that
> suffers from the problem that malignmark was trying to address of
> breaking up the expression structure.
>
>
>
>> Another question is whether the malignmark must appear always inside a
>> table (mtable)
>>
> as specified yes.
>
>  or can be used also combined with <mspace
>
>> linebreak=3D"newline"/>. For example, is the following a valid alternati=
ve?
>>
>>    <mrow>
>>
>>      <mi>y</mi>
>>
>>      <malignmark/>
>>
>>      <mo> =3D </mo>
>>
>>     <mi>x</mi>
>>
>>      <mo>+</mo>
>>
>>      <mn>1</mn>
>>
>>      <mspace linebreak=3D"newline"/>
>>
>>      <mi>x</mi>
>>
>>      <mo>+</mo>
>>
>>      <mn>1</mn>
>>
>>      <malignmark/>
>>
>>      <mo> =3D </mo>
>>
>>      <mi>y</mi>
>>
>>    </mrow>
>>
>> Dani
>>
>>
> I was going to show that that was invalid but it turns out that
> it is invalid according to the prose but the constraint that malignmark
> only appears in tables isn't checked by the schema. (In principle it
> could do but it would greatly complicate the relax schema as you'd have
> to carry the fact that you were inside a table through arbitrary pattern
> rules.  I suppose the XSD schema could have had an xpath assertion
> saying explicitly that all malignmark are within a table.
>
>
> David
>
> ________________________________
>
>
> The Numerical Algorithms Group Ltd is a company registered in England and
> Wales with company number 1249803. The registered office is:
>
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
>
>
> This e-mail has been scanned for all viruses by Microsoft Office 365.
>
> ________________________________
>
>

--047d7b45070e55ab7805273632ea
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div>David&#39;s solution is widely used an=
d is what people do in TeX. You do need add some spacing around the &#39;=
=3D&#39; though (probably by overriding columnspacing).<br><br>Another opti=
on that is widely supported in renderers is to use &lt;mphantom&gt; to get =
alignment. That&#39;s pretty hacky though.<br><br></div>There are also opti=
ons to use with indenttarget, although that still isn&#39;t well implemente=
d even though it isn&#39;t that hard to implement. It works well if the fir=
st equation is the left of the second. I.e., if you had<br>x+1=3Dy<br></div=
>=C2=A0=C2=A0=C2=A0 y=3Dx+1<br><br></div>because you can put the target on =
the &#39;1&#39;.<br><br></div>Perhaps in MathML 4 we could add a variant of=
 indenting so that all marked characters align (only the first on a line --=
 that would handle the common cases and avoid the complications with malign=
group/malignmark that have caused others to put off implementing maligngrou=
p/malignmark.<br><br>Neil Soiffer<br><span class=3D"">Senior</span> <span c=
lass=3D"">Scientist</span><br>Design Science, Inc.<br><a href=3D"http://www=
.dessci.com" target=3D"_blank">www.dessci.com</a><br>~ Makers of MathType, =
MathFlow, MathPlayer, MathDaisy, Equation Editor ~<br><span><font color=3D"=
#888888"><span></span></font></span><div><div><img class=3D"" src=3D"https:=
//ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif"></div></div><br> </=
div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Fri, Dec 1=
8, 2015 at 9:20 AM, David Carlisle <span dir=3D"ltr">&lt;<a href=3D"mailto:=
[email protected]" target=3D"_blank">[email protected]</a>&gt;</span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div class=3D"HOEnZb"><div class=3D"h5">O=
n 18/12/2015 16:56, Daniel Marques wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Dear MathML group,<br>
<br>
I=E2=80=99m just wandering how to align formulas given a symbol. For exampl=
e,<br>
<br>
__y=3Dx+1<br>
<br>
x+1=3Dy<br>
<br>
(where the _ are spaces)<br>
<br>
Reading the MathML specification, I came up with<br>
<br>
&lt;mtable&gt;<br>
<br>
=C2=A0 =C2=A0&lt;mtd&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mi&gt;y&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;malignmark/&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt; =3D &lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 &lt;mi&gt;x&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt;+&lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mn&gt;1&lt;/mn&gt;<br>
<br>
=C2=A0 =C2=A0&lt;/mtd&gt;<br>
<br>
=C2=A0 &lt;mtd&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mi&gt;x&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt;+&lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mn&gt;1&lt;/mn&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;malignmark/&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt; =3D &lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mi&gt;y&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0&lt;/mtd&gt;<br>
<br>
&lt;/mtable&gt;<br>
<br>
Do you think that this is the best way to express that?<br>
</blockquote>
<br></div></div>
Apart from a missing mtr (was optional in mathml 1 but not since)<br>
yes but.....<br>
<br>
<br>
malignmark is one of the trickier areas of mathml and not supported<br>
in all mathml renderers so if you are targetting a specific system and<br>
it works then fine, otherwise I&#39;d split it as two columns right aligned=
<br>
for the left hand side and left aligned for the rest. Of course that<br>
suffers from the problem that malignmark was trying to address of<br>
breaking up the expression structure.<span class=3D""><br>
<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
<br>
Another question is whether the malignmark must appear always inside a<br>
table (mtable)<br>
</blockquote></span>
as specified yes.<span class=3D""><br>
<br>
=C2=A0or can be used also combined with &lt;mspace<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
linebreak=3D&quot;newline&quot;/&gt;. For example, is the following a valid=
 alternative?<br>
<br>
=C2=A0 =C2=A0&lt;mrow&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mi&gt;y&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;malignmark/&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt; =3D &lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 &lt;mi&gt;x&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt;+&lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mn&gt;1&lt;/mn&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mspace linebreak=3D&quot;newline&quot;/&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mi&gt;x&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt;+&lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mn&gt;1&lt;/mn&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;malignmark/&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mo&gt; =3D &lt;/mo&gt;<br>
<br>
=C2=A0 =C2=A0 =C2=A0&lt;mi&gt;y&lt;/mi&gt;<br>
<br>
=C2=A0 =C2=A0&lt;/mrow&gt;<br>
<br>
Dani<br>
<br>
</blockquote>
<br></span>
I was going to show that that was invalid but it turns out that<br>
it is invalid according to the prose but the constraint that malignmark<br>
only appears in tables isn&#39;t checked by the schema. (In principle it<br=
>
could do but it would greatly complicate the relax schema as you&#39;d have=
<br>
to carry the fact that you were inside a table through arbitrary pattern<br=
>
rules.=C2=A0 I suppose the XSD schema could have had an xpath assertion<br>
saying explicitly that all malignmark are within a table.<br>
<br>
<br>
David<br>
<br>
________________________________<br>
<br>
<br>
The Numerical Algorithms Group Ltd is a company registered in England and W=
ales with company number 1249803. The registered office is:<br>
<br>
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.<br>
<br>
<br>
<br>
This e-mail has been scanned for all viruses by Microsoft Office 365.<br>
<br>
________________________________<br>
<br>
</blockquote></div><br></div>

--047d7b45070e55ab7805273632ea--