LaTeX forum ⇒ GeneralEquation left alignment using align

LaTeX specific issues not fitting into one of the other forums of this category.
fenghedo
Posts: 19
Joined: Sat Oct 04, 2008 3:01 pm

Equation left alignment using align

Postby fenghedo » Sat Oct 04, 2008 3:08 pm

Hi all,
I know one could use align in the following manner to align equations
  1. \begin{align*}
  2. A&=B\\
  3. &=C
  4. \end{align*}

But I have a long equation and I want to save some space by doing the following
  1. \begin{align*}
  2. &A\\
  3. &=B\\
  4. &=C
  5. \end{align*}

But the whole equation just got pushed way right and left a big blank space on the left.

Is there any way I could tell LaTeX to align the whole thing left?

Thanks.

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 » Sat Oct 04, 2008 3:22 pm

I'm not sure whether I understand you right. You could set the fleqn (force left equation) option for the document class.


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

fenghedo
Posts: 19
Joined: Sat Oct 04, 2008 3:01 pm

Postby fenghedo » Sat Oct 04, 2008 3:31 pm

Thanks localghost. I did that and now it aligns to the left. However, LaTeX still leaves a margin of about 4 spaces to the left of the whole equation (I guess this is supposed to make it look nicer in the surrounding text environment). Please see the attached image.

Is there any way I could remove this shift?

Thanks.
Attachments
left_alignment.JPG
left_alignment.JPG (13.85 KiB) Viewed 16206 times

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 » Sat Oct 04, 2008 3:43 pm

Giving help would be easier if you provided the code of this excerpt shown in the screenshot.
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

fenghedo
Posts: 19
Joined: Sat Oct 04, 2008 3:01 pm

Postby fenghedo » Sat Oct 04, 2008 4:26 pm

localghost wrote:Giving help would be easier if you provided the code of this excerpt shown in the screenshot.


  1. Then equation something can be written as
  2. \begin{align}
  3. &E_{ic} = \frac{1}{N}\sum\limits_{z_k\in V} \left[
  4. \norm{m_f(z_k;\mu_f) + m_b(z_k+m_f(z_k;\mu_f);\mu_b)}^2 \right.\notag\\
  5. &\quad \left. +\norm{m_b(z_k;\mu_b) + m_f(z_k+m_b(z_k;\mu_b); \mu_f)}^2
  6. \right] \notag\\
  7. & = \frac{1}{N}\sum\limits_{z_k\in V} \left[
  8. \norm{\begin{bmatrix}
  9. m_{fx}(z_k;\mu_{fx}) + m_{bx}(z_k+m_f(z_k;\mu_{f});\mu_{bx})\\
  10. m_{fy}(z_k;\mu_{fy}) + m_{by}(z_k+m_f(z_k;\mu_{f});\mu_{by})
  11. \end{bmatrix}}^2 \right.\notag\\
  12. &\quad \left. +\norm{\begin{bmatrix}
  13. m_{bx}(z_k;\mu_{bx}) + m_{fx}(z_k+m_b(z_k;\mu_{b}); \mu_{fx})\\
  14. m_{by}(z_k;\mu_{by}) + m_{fy}(z_k+m_b(z_k;\mu_{b}); \mu_{fy})
  15. \end{bmatrix}}^2
  16. \right] \notag\\
  17. \end{align}


I've seen people put full width equations in double column layouts. Do you know how to do that?


Thanks. I really appreciate the help.

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 7804
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sat Oct 04, 2008 4:38 pm

Hi fenghedo,

fenghedo wrote:However, LaTeX still leaves a margin of about 4 spaces to the left of the whole equation. Is there any way I could remove this shift?


Just set \mathindent to 0pt:
  1. \setlength{\mathindent}{0pt}

Btw. in the first line of the formula above you probably want to write
  1. E_{ic} &= \frac{1}{N} ...

look at the position of the &.

Stefan
Site admin

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 » Sat Oct 04, 2008 5:20 pm

Another way of aligning could be the following.
  1. \begin{align*}
  2. E_{ic}=
  3. \begin{split}
  4. & \frac{1}{N}\sum\limits_{z_k\in V} \left[\norm{m_f(z_k;\mu_f) + m_b(z_k+m_f(z_k;\mu_f);\mu_b)}^2 \right. \\
  5. & \left. +\norm{m_b(z_k;\mu_b) + m_f(z_k+m_b(z_k;\mu_b); \mu_f)}^2 \right]
  6. \end{split}\\
  7. =
  8. \begin{split}
  9. & \frac{1}{N}\sum\limits_{z_k\in V} \left[
  10. \norm{\begin{bmatrix}
  11. m_{fx}(z_k;\mu_{fx}) + m_{bx}(z_k+m_f(z_k;\mu_{f});\mu_{bx})\\
  12. m_{fy}(z_k;\mu_{fy}) + m_{by}(z_k+m_f(z_k;\mu_{f});\mu_{by})
  13. \end{bmatrix}}^2 \right. \\
  14. & \left. +\norm{\begin{bmatrix}
  15. m_{bx}(z_k;\mu_{bx}) + m_{fx}(z_k+m_b(z_k;\mu_{b}); \mu_{fx})\\
  16. m_{by}(z_k;\mu_{by}) + m_{fy}(z_k+m_b(z_k;\mu_{b}); \mu_{fy})
  17. \end{bmatrix}}^2 \right]
  18. \end{split}
  19. \end{align*}
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

User avatar
Juanjo
Posts: 656
Joined: Sat Jan 27, 2007 12:46 am

Postby Juanjo » Sun Oct 05, 2008 11:39 pm

I assume that you have defined \norm more or less by \newcommand{\norm}[1]{\left\Vert#1\right\Vert}.

The solution proposed by localghost works if you replace \begin{split} by \begin{aligned}[t], and \end{split} by \end{aligned}. Anyway, I would remark the following facts:
  • The equation number usually is vertically centered, which is not the case in your code. This can be simply achieved by replacing align by a combination of equation and split.
  • You break lines which contain brackets in such a way that the opening bracket falls in one line and the closing one, in the second line. If you use \left - \right to fix the size of brackets, it may happen that the opening and closing brackets have different sizes, depending on the mathematical surrounding expressions. I find better to manually fix sizes.
  • Since breaks happens inside a bracketed expression, the alignment point should on the left of the opening bracket.

Taking these points into account, I would propose the following code:
  1. \begin{equation}
  2. \begin{split}
  3. E_{ic}&=\!
  4. \begin{aligned}[t]
  5. \frac{1}{N}\sum_{z_k\in V} \Bigl[&\norm{m_f(z_k;\mu_f)
  6. + m_b(z_k+m_f(z_k;\mu_f);\mu_b)}^2 \Bigr. \\
  7. \Bigl. & +\norm{m_b(z_k;\mu_b) + m_f(z_k+m_b(z_k;\mu_b); \mu_f)}^2 \Bigr]
  8. \end{aligned}\\
  9. &=\!
  10. \begin{aligned}[t]
  11. \frac{1}{N}\sum_{z_k\in V} \Biggl[
  12. &\norm{\begin{bmatrix}
  13. m_{fx}(z_k;\mu_{fx}) + m_{bx}(z_k+m_f(z_k;\mu_{f});\mu_{bx})\\
  14. m_{fy}(z_k;\mu_{fy}) + m_{by}(z_k+m_f(z_k;\mu_{f});\mu_{by})
  15. \end{bmatrix}}^2 \Biggr. \\
  16. \Biggl. & +\norm{\begin{bmatrix}
  17. m_{bx}(z_k;\mu_{bx}) + m_{fx}(z_k+m_b(z_k;\mu_{b}); \mu_{fx})\\
  18. m_{by}(z_k;\mu_{by}) + m_{fy}(z_k+m_b(z_k;\mu_{b}); \mu_{fy})
  19. \end{bmatrix}}^2 \Biggr].
  20. \end{aligned}
  21. \end{split}
  22. \end{equation}

I have also added a point at the end. Mathematical expressions should be punctuated with commas and points, as done with ordinary text.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

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


Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests