LaTeX forum ⇒ Math & Sciencemultiple alignment points and \split environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Drugbird
Posts: 2
Joined: Tue Aug 31, 2010 3:13 pm

multiple alignment points and \split environment

Postby Drugbird » Tue Aug 31, 2010 3:31 pm

Hi there,

I'd like to display a two line equation aligned in more than one place across two lines, but only supply it with one number.

I.e. in an equation like:
a=b=c
ab=bc=c^2

I'd like the = signs to be aligned vertically, and I want 1 equation number to the right halfway between the two lines.

I know alignment can be done with \alignat, and the numbering can be done with \split, but I can't seem to get both things at once.

MWE:
  1. \documentclass[10pt,a4paper]{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \section{Test}
  5. \begin{alignat}{3}
  6. a&={}&b&={}&c\\
  7. ab&={}&bc&={}&c^2
  8. \end{alignat}
  9.  
  10. \begin{alignat}{3}
  11. a&=b&=c\\
  12. ab&=bc&=c^2
  13. \end{alignat}
  14.  
  15. \begin{equation}
  16. \begin{split}
  17. a&=b=c\\
  18. ab&=bc=c^2
  19. \end{split}
  20. \end{equation}
  21.  
  22. \end{document}



Also, alignat seems to require an extra {}& per equal sign that I don't quite understand (top equation in the MWE, since the one below has strange spacing). Could someone explain this to me?

Furthermore, the split environment will produce error messages if I put more & symbols on one line. For example, inserting this in the MWE will produce error messages:
  1. \begin{equation}
  2. \begin{split}
  3. a&=b&=c\\
  4. ab&=bc&=c^2
  5. \end{split}
  6. \end{equation}


Could someone help me align and number things the way I like? Thanks in advance.

(Some more details I'm not quite sure are useful: I use WinEdt 6.0 with MikTex 2.8 and PDFTexify)
Last edited by Drugbird on Thu Sep 02, 2010 1:00 pm, edited 1 time in total.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Tue Aug 31, 2010 6:01 pm

It has to look a bit different. The code below shows only the relevant part.
  1. \begin{equation}
  2. \begin{alignedat}{2}
  3. a &= b & &= c\\
  4. ab &= bc & &= c^2
  5. \end{alignedat}
  6. \end{equation}

See the amsmath manual for details. More stuff about math typesetting can be found in the »Math mode« document.


Best regards and welcome to the board
Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links

Drugbird
Posts: 2
Joined: Tue Aug 31, 2010 3:13 pm

Postby Drugbird » Thu Sep 02, 2010 1:08 pm

Thanks a lot, localghost. This is exactly what I was looking for.

I'm still not quite sure though why you need three & symbols per line. My reasoning is that there are only two equal signs that need to be aligned, so you'd also need two & symbols. I tried searching the amsmath documentation, but was unable to find it... Any help?

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Thu Sep 02, 2010 7:43 pm

Drugbird wrote:[…] I'm still not quite sure though why you need three & symbols per line. My reasoning is that there are only two equal signs that need to be aligned, so you'd also need two & symbols. I tried searching the amsmath documentation, but was unable to find it. […]

Consider the alignat environment as an array with special alignment of the columns.
  1. \begin{array}{@{}r@{\,=\,}lr@{\,=\,}l@{}}
  2. a & b & c \\
  3. aa & bb & cc
  4. \end{array}

If you declare an alignat environment with n as its mandatory argument for the number of equal signs to be aligned, you will need n+1 alignment characters (ampersands) to get the right alignment. Take a look at Sections 3.6 and 3.7 of the amsmath manual. You can find similar descriptions in the »Math mode« document.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Math & Science”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests