# left position math formula

I try to write down the following equation:

\begin{flalign*} \left \| \vec{r}_1 - \vec{r}_2 \right \| = \\ \sqrt{( r_{1,x}-r_{2,x} )^2 + ( r_{1,y} - r_{2,y} )^2 } = \\ \sqrt{( (x\cos(\Omega y)-y\sin(\Omega y))+\rho\cos(\Omega y) )^2 + ( x\sin(\Omega y)+y\cos(\Omega y) + \rho\sin(\Omega y) )^2 } \end{flalign*}


I am using the following math packages:

\usepackage{amsmath}
\usepackage{mathtools}


But instead to be write on the left side it's continuing to stay in the right side. How can I write it in a better way?

Thanks a lot!

-
Is the fleqn option of article what you want? – Raphael Feb 1 '14 at 21:35

First of all, flalign* starts math mode, so can not be nested inside equation.

Then, if you want the stuff inside flalign* to be left aligned, you have to put a & at the beginning of each line and a && at its end, like this:

\documentclass{article}

\begin{document}
\begin{flalign*}
&\left \| \vec{r}_1 - \vec{r}_2 \right \| = &&\\
&\sqrt{( r_{1,x}-r_{2,x} )^2 + ( r_{1,y} - r_{2,y} )^2 } = &&\\
&\sqrt{( x\cos(\Omega y)-y\sin(\Omega y)+\rho\cos(\Omega y) )^2 + ( x\sin(\Omega y)+y\cos(\Omega y) + \rho\sin(\Omega y) )^2 }&&
\end{flalign*}
\end{document}


The result is not really good, anyway. BTW, there was an unneeded right parenthesis after y\sin(\Omega y) and one before x\cos(\Omega y).

IMHO, you can also further eliminate parenthesis so to avoid bad boxes warnings, and move the equal sign down in the next line, in this way

\documentclass{article}

\begin{document}
\begin{flalign*}
&\left \| \vec{r}_1 - \vec{r}_2 \right \| &&\\
&\quad=\sqrt{( r_{1,x}-r_{2,x} )^2 + ( r_{1,y} - r_{2,y} )^2 } &&\\
&\quad=\sqrt{( x\cos\Omega y-y\sin\Omega y+\rho\cos\Omega y )^2 + ( x\sin\Omega y+y\cos\Omega y + \rho\sin\Omega y )^2 }&&
\end{flalign*}
\end{document}


For a better looking square root you can insert a \vphantom{r_1^2} in the latter \sqrt:

\documentclass{article}

\begin{document}
\begin{flalign*}
&\left \| \vec{r}_1 - \vec{r}_2 \right \| &&\\
&\quad=\sqrt{( r_{1,x}-r_{2,x} )^2 + ( r_{1,y} - r_{2,y} )^2 } &&\\
&\quad=\sqrt{\vphantom{r_1^2}( x\cos\Omega y-y\sin\Omega y+\rho\cos\Omega y )^2 + ( x\sin\Omega y+y\cos\Omega y + \rho\sin\Omega y )^2 }&&
\end{flalign*}
\end{document}


-
Maybe a \quad to start the third row? – egreg Feb 1 '14 at 16:39
@egreg Right, no bad boxes. – karlkoeller Feb 1 '14 at 16:59
Another option might be using multlined environment inside the last square root. – Manuel Feb 1 '14 at 17:27
Since the mathtools package loads the amsmath package, it's not necessary to load the latter package explicitly. To normalize the size of the two long square root symbols, you could encase the former in a \smash{...}, or at least a \smash[b]{...}, instruction. – Mico Feb 1 '14 at 17:32
@Mico Thanks, just copied the code and didn't notice that both package were loaded. In regards of \smashing the former, I prefer the result with a \vphantom. – karlkoeller Feb 1 '14 at 18:14

Is this what you want?

\begin{align*}
&\left \| \vec{r}_1 - \vec{r}_2 \right \| = \\
&\sqrt{( r_{1,x}-r_{2,x} )^2 + ( r_{1,y} - r_{2,y} )^2 } = \\
&\sqrt{( (x\cos(\Omega y)-y\sin(\Omega y))+\rho\cos(\Omega y) )^2 + ( x\sin(\Omega y)+y\cos(\Omega y) + \rho\sin(\Omega y) )^2 }
\end{align*}


-

Or this

\documentclass[]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
%\begin{align*} \left \| \vec{r}_1 - \vec{r}_2 \right \| &= \sqrt{( r_{1,x}-r_{2,x} )^2 + ( r_{1,y} - r_{2,y} )^2 } \\ &= \sqrt{( (x\cos(\Omega y)-y\sin(\Omega y))+\rho\cos(\Omega y) )^2 + ( x\sin(\Omega y)+y\cos(\Omega y) + \rho\sin(\Omega y) )^2 } \end{align*} %
\end{document}

-
The bad box is over 52pt... – karlkoeller Feb 1 '14 at 16:31
@karlkoeller -- Mmmm, leaned sth from your post. Thanks. – Jesse Feb 1 '14 at 17:06
Just a quick note, the bad box is removed if the left margin is reduced. This example uses the default setting of LaTeX. – Jesse Feb 1 '14 at 17:30

Here's another option. Taking karlkoeller's code.
I use multlined environment inside the second square root (\qquad is just to move it to the right, you can substitute it with whatever you want, even delete it, since multline already adds some space).

\begin{align*}
\left\| \vec{r}_1 - \vec{r}_2 \right\| &= \sqrt{(r_{1,x} - r_{2,x})^2 + (r_{1,y} - r_{2,y})^2 } \\
&= \sqrt{\begin{multlined}
(x\cos\Omega y - y\sin\Omega y + \rho\cos\Omega y)^2 \\
\qquad + (x\sin\Omega y + y\cos\Omega y + \rho\sin\Omega y)^2
\end{multlined}}
\end{align*}


## EDIT

Still another two options.

\begin{align*}
\left\| \vec{r}_1 - \vec{r}_2 \right\| &= \sqrt{(r_{1,x} - r_{2,x})^2 + (r_{1,y} - r_{2,y})^2 } \\
\MoveEqLeft = \sqrt{\vphantom{r_1^2} (x\cos\Omega y - y\sin\Omega y + \rho\cos\Omega y)^2 + (x\sin\Omega y + y\cos\Omega y + \rho\sin\Omega y)^2}
\end{align*}

\begin{multline*}
\left\| \vec{r}_1 - \vec{r}_2 \right\| = \sqrt{(r_{1,x} - r_{2,x})^2 + (r_{1,y} - r_{2,y})^2 } \\
= \sqrt{\vphantom{r_1^2} (x\cos\Omega y - y\sin\Omega y + \rho\cos\Omega y)^2 + (x\sin\Omega y + y\cos\Omega y + \rho\sin\Omega y)^2}
\end{multline*}


Both of them look similar to this:

-