Featured Book

LaTeX Beginners Guide

Who is online

In total there are 20 users online :: 1 registered, 0 hidden and 19 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

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

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Equation left alignment using align

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

Equation left alignment using align

Postby fenghedo on Sat Oct 4th, 2008

Hi all,
I know one could use align in the following manner to align equations
Code: Select all  •  Open in writeLaTeX
\begin{align*}
A&=B\\
 &=C
\end{align*
}

But I have a long equation and I want to save some space by doing the following
Code: Select all  •  Open in writeLaTeX
\begin{align*}
&A\\
&=B\\
&=C
\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.
fenghedo
 
Posts: 19
Joined: Sat Oct 4th, 2008

Re: Equation left alignment using align

Postby localghost on Sat Oct 4th, 2008

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
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: Equation left alignment using align

Postby fenghedo on Sat Oct 4th, 2008

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 13406 times
fenghedo
 
Posts: 19
Joined: Sat Oct 4th, 2008

Re: Equation left alignment using align

Postby localghost on Sat Oct 4th, 2008

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
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: Equation left alignment using align

Postby fenghedo on Sat Oct 4th, 2008

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


Code: Select all  •  Open in writeLaTeX
Then equation something can be written as
\begin{align}
&E_{ic}  = \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.\notag\\
        &\quad \left. +\norm{m_b(z_k;\mu_b) + m_f(z_k+m_b(z_k;\mu_b); \mu_f)}^2
        \right
]  \notag\\
        & = \frac{1}{N}\sum\limits_{z_k\in V} \left[
        \norm{\begin{bmatrix}
                m_{fx}(z_k;\mu_{fx}) + m_{bx}(z_k+m_f(z_k;\mu_{f});\mu_{bx})\\
                m_{fy}(z_k;\mu_{fy}) + m_{by}(z_k+m_f(z_k;\mu_{f});\mu_{by})
                \end{bmatrix}}^2 \right.\notag\\
        &\quad \left. +\norm{\begin{bmatrix}
                m_{bx}(z_k;\mu_{bx}) + m_{fx}(z_k+m_b(z_k;\mu_{b}); \mu_{fx})\\
                m_{by}(z_k;\mu_{by}) + m_{fy}(z_k+m_b(z_k;\mu_{b}); \mu_{fy})
                \end{bmatrix}}^2
        \right
]  \notag\\
       
\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.
fenghedo
 
Posts: 19
Joined: Sat Oct 4th, 2008

Re: Equation left alignment using align

Postby Stefan_K on Sat Oct 4th, 2008

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:
Code: Select all  •  Open in writeLaTeX
\setlength{\mathindent}{0pt}

Btw. in the first line of the formula above you probably want to write
Code: Select all  •  Open in writeLaTeX
E_{ic} &= \frac{1}{N} ...

look at the position of the &.

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6387
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Equation left alignment using align

Postby localghost on Sat Oct 4th, 2008

Another way of aligning could be the following.
Code: Select all  •  Open in writeLaTeX
\begin{align*}
  E_{ic}=
  \begin{split}
    & \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. \\
    & \left. +\norm{m_b(z_k;\mu_b) + m_f(z_k+m_b(z_k;\mu_b); \mu_f)}^2 \right
]
  \end{split}\\
  =
  \begin{split}
    & \frac{1}{N}\sum\limits_{z_k\in V} \left[
      \norm{\begin{bmatrix}
            m_{fx}(z_k;\mu_{fx}) + m_{bx}(z_k+m_f(z_k;\mu_{f});\mu_{bx})\\
            m_{fy}(z_k;\mu_{fy}) + m_{by}(z_k+m_f(z_k;\mu_{f});\mu_{by})
          \end{bmatrix}}^2 \right. \\
    & \left. +\norm{\begin{bmatrix}
      m_{bx}(z_k;\mu_{bx}) + m_{fx}(z_k+m_b(z_k;\mu_{b}); \mu_{fx})\\
      m_{by}(z_k;\mu_{by}) + m_{fy}(z_k+m_b(z_k;\mu_{b}); \mu_{fy})
      \end{bmatrix}}^2 \right
]
  \end{split}
\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
User avatar
localghost
Site Moderator
 
Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

Re: Equation left alignment using align

Postby Juanjo on Sun Oct 5th, 2008

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:
Code: Select all  •  Open in writeLaTeX
\begin{equation}
   \begin{split}
     E_{ic}&=\!
     \begin{aligned}[t]
        \frac{1}{N}\sum_{z_k\in V} \Bigl[&\norm{m_f(z_k;\mu_f)
         + m_b(z_k+m_f(z_k;\mu_f);\mu_b)}^2 \Bigr. \\
         \Bigl. & +\norm{m_b(z_k;\mu_b) + m_f(z_k+m_b(z_k;\mu_b); \mu_f)}^2 \Bigr
]
     \end{aligned}\\
     &=\!
     \begin{aligned}[t]
        \frac{1}{N}\sum_{z_k\in V} \Biggl[
        &\norm{\begin{bmatrix}
            m_{fx}(z_k;\mu_{fx}) + m_{bx}(z_k+m_f(z_k;\mu_{f});\mu_{bx})\\
            m_{fy}(z_k;\mu_{fy}) + m_{by}(z_k+m_f(z_k;\mu_{f});\mu_{by})
          \end{bmatrix}}^2 \Biggr. \\
        \Biggl. & +\norm{\begin{bmatrix}
         m_{bx}(z_k;\mu_{bx}) + m_{fx}(z_k+m_b(z_k;\mu_{b}); \mu_{fx})\\
         m_{by}(z_k;\mu_{by}) + m_{fy}(z_k+m_b(z_k;\mu_{b}); \mu_{fy})
       \end{bmatrix}}^2 \Biggr
].
     \end{aligned}
  \end{split}
\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.
User avatar
Juanjo
 
Posts: 656
Joined: Sat Jan 27th, 2007


Return to General

Who is online

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