Align at Equals sign

2,975 views
Skip to first unread message

Stuart B

unread,
May 22, 2012, 10:19:19 PM5/22/12
to mathja...@googlegroups.com
Is there a simple way to align equations at the equals sign? Its particularly useful when showing a derivation. There is some information here:
http://www.w3.org/TR/MathML3/chapter3.html#type.group-align but it is not working for me and I was wondering if there is a MathJax specific write up.

lumo

unread,
May 23, 2012, 6:12:20 AM5/23/12
to mathja...@googlegroups.com
It's a standard LaTeX construction that answers your question. Look e.g. at


Press page-down about 4 times to see the equation starting with Prob(no marble). With my macros, you may see that the source is

\eq{ 
Prob(\text{no marble}) &= \frac{1/P-1}{1/P-F} =\\ &= \frac{1-P}{1-FP} 
}

I sometimes like to use it so I created a macro called "eq" that makes it simple. In the initialization of MathJax, I have

<script type='text/x-mathjax-config'>
MathJax.Hub.Config({
TeX: {
Macros: {
dd: '{\\rm d}', (.... many others.....)

eq: ['\\begin{align} #1 \\end{align}',1],
iddots: "{\\kern3mu\\raise1mu{.}\\kern3mu\\raise6mu{.}\\kern3mu\\raise12mu{.}}"
}
                                         },

and so on. You may see that the equations must be written between \begin{align} and \end{align}, the lines are separated by double backslashes \\, and the point at each equation (in front of "=" in your case which is the most typical one) one must write ampersend & to get the places aligned.

You may want to quick-study the 4-page and 150-page introductions to LaTeX:


All the best
Lubos


Dne středa, 23. května 2012 0:19:19 UTC+2 Stuart B napsal(a):

Davide P. Cervone

unread,
May 23, 2012, 1:54:26 PM5/23/12
to mathja...@googlegroups.com
There are still a number of MathML3 table features that are missing from MathJax, and the <maligngroup> and related <malignmark> are among them.  For now, you will have to use <mtable> directly.  If you are working from TeX, there are the AMSmath environments like \begin{align}...\end{align} that have already been mentioned.  If you are producing MathML some other way, you will need to generate <mtable> elements like the following:

<math xmlns="http://www.w3.org/1998/Math/MathML"> <mtable columnalign="right left" columnspacing="0.28em" displaystyle="true"> <mtr> <mtd> <mi>x</mi> </mtd> <mtd> <mo>=</mo> <mi>a</mi> </mtd> </mtr> <mtr> <mtd> <mi>y</mi> </mtd> <mtd> <mo>=</mo> <mi>b</mi> </mtd> </mtr> </mtable> </math>

Hope that helps.

Davide

Stuart B

unread,
May 24, 2012, 5:14:50 AM5/24/12
to mathja...@googlegroups.com
. It works using <mtr> the end result is here:
http://www.pveducation.org/pvcdrom/pn-junction/total-current
I found I could put the tags around nothing and get the alignment required.
Thanks very much for the responses I would never have figured this out on my own

I'm presently using MathM over TeX as I hope that one day equations will render natively without needing MathJax
Reply all
Reply to author
Forward
0 new messages