# How to align equations in two columns?

Well, my problem is I'm trying to find a way to write many equations and divide these into columns as you would when writing on paper, cut in some part and continue. I have achieved almost using the aligned function of the amsmath package. I would just like these appear not centered vertically, but continue as I write text in two columns.

Here's my code

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
\begin{aligned}
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial  \mu} & = -\frac{1}      {2\sigma^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)=0 \\
& = -\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}+n\mu=0\\
& \Rightarrow \sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}=n\mu\\
& \Rightarrow     \tilde{\mu}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}}{n}=\bar{y}_{..} \\
\end{aligned}
\begin{aligned}[c]
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial  \sigma^{2}} &     =\frac{-n}{2\sigma^{2}}+\frac{1}   {2(\sigma^{2})^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}=0 \\
& \Rightarrow    \tilde{\sigma}^{2}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}}{n}  \\
& \Rightarrow   \tilde{\sigma}^{2}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-  \bar{y}_{..})^{2}}{n}
\end{aligned}
\end{equation*}
\end{document} • You say you are writing in two columns but your example is of a single column document? Did you mean to add twocolumn to the document class options?? – David Carlisle Jan 17 '16 at 20:21
• My document is a single column document, I want only the equations appear in two columns. – Héctor Jan 17 '16 at 20:24

Simple, just use the [t] option for the aligned construct.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation*}
\begin{aligned}[t]
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial  \mu} & = -\frac{1}      {2\sigma^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)=0 \\
& = -\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}+n\mu=0\\
& \Rightarrow \sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}=n\mu\\
& \Rightarrow     \tilde{\mu}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}}{n}=\bar{y}_{..} \\
\end{aligned}
\begin{aligned}[t]
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial  \sigma^{2}} &     =\frac{-n}{2\sigma^{2}}+\frac{1}   {2(\sigma^{2})^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}=0 \\
& \Rightarrow    \tilde{\sigma}^{2}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}}{n}  \\
& \Rightarrow   \tilde{\sigma}^{2}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-  \bar{y}_{..})^{2}}{n}
\end{aligned}
\end{equation*}

\end{document} What you want, as I understand it, is best obtained with alignat environment, from amsmath:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{alignat*}{2}
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial \mu} & = -\frac{1} {2\sigma^{2}} \sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)=0
& = -\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}+n\mu=0
& & \Rightarrow \tilde{\sigma}^{2}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}}{n}\\
& \Rightarrow \sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}=n\mu & & \Rightarrow \tilde{\sigma}^{2}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}- \bar{y}_{..})^{2}}{n} \\
& \Rightarrow \tilde{\mu}=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}}{n}=\bar{y}_{..} \\
\end{alignat*}

\end{document} • Visually, your solution is what I want. But, I thought you could cut the text and then continue. I find it cumbersome to write in parallel step 1 with step 10. – Héctor Jan 17 '16 at 20:44
• You can use you solution, only replacing aligned[c] with aligned[t] for each group. However this will align only the first line of each group. If you find the result acceptable, do it. In that case, you can try to align subsequent lines using \\[some vertical spacing], to be determined experimentally, but this may be as cumbersome as the alignat solution. – Bernard Jan 17 '16 at 20:55

You could do something like this to avoid having to enter the steps "in parallel" however it was too wide to fit in two columns so I split some lines up, perhaps your linewidth so now it looks a bit spaced out. But the basic idea is to use \allowdisplaybreaks and multicols \documentclass{article}
\usepackage{amsmath,multicol}
\allowdisplaybreaks
\begin{document}

\section{Zzzz}

Some text some text  some text  some text.
Some text some text  some text  some text.
\begin{multicols}{2}
\begin{align*}
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial  \mu} &
= -\frac{1}      {2\sigma^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)\\
&=0
\\
& = -\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}+n\mu\\
&=0\\
& \Rightarrow \sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}=n\mu\\
& \Rightarrow     \tilde{\mu}\\
&=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}y_{ij}}{n}=\bar{y}_{..} \\
\frac{\partial l(\mu, \sigma|\mathbf{y})}{\partial  \sigma^{2}} &=\frac{-n}{2\sigma^{2}}+\\
&\shoveright{\frac{1}   {2(\sigma^{2})^{2}}\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}}\\
&=0 \\
& \Rightarrow    \tilde{\sigma}^{2}\\
&=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-\mu)^{2}}{n}  \\
& \Rightarrow   \tilde{\sigma}^{2}\\
&=\frac{\sum_{i=1}^{a}\sum_{j=1}^{n_{i}}(y_{ij}-  \bar{y}_{..})^{2}}{n}\\
\mbox{}\\ % help balance
\mbox{}
\end{align*}
\end{multicols}
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
Some text some text  some text  some text.
\end{document}