# how to adjust this algorithm

I have an algorithm and I would like to adjust it to look good. I have some matrices and some equations, so I would like to put the text in the left not in the center.

\documentclass[11pt,twocolumn]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{amsmath}

\begin{document}
\begin{algorithm}[h]
\caption{title}

\begin{algorithmic}[1]
\For  {all }
\State{
\begin{equation*}
\begin{bmatrix}
a \\
a \\
a \\
\end{bmatrix}
=
\begin{bmatrix}
b \\
b \\
b \\
\end{bmatrix}
\end{equation*}
\For {aaaa}
\State{
\begin{align*}
\delta_{p} &=
\begin{bmatrix}
e \\
e
\end{bmatrix} \\
W &= W      \\
S &= S \\
D &= D
\end{align*}
}
\EndFor
\State{
\begin{align*}
a &=a \\
a &= a
\end{align*}
}
}
\EndFor

\end{algorithmic}
\end{algorithm}
\end{document}


Also, I'm using align which increases the vertical space between lines. Is there any way to decrease the vertical space?

Here is one attempt:

\documentclass[11pt,twocolumn]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{algpseudocode}
\usepackage{algorithm}
\usepackage{amsmath}

\begin{document}
\begin{algorithm}[h]
\caption{title}

\begin{algorithmic}[1]
\setlength{\lineskip}{3pt}
\For  {all }
\State{
$\begin{bmatrix} a \\ a \\ a \\ \end{bmatrix} = \begin{bmatrix} b \\ b \\ b \\ \end{bmatrix}$
\For {aaaa}
\State{
\begin{aligned}[t] \delta_{p} &= \begin{bmatrix} e \\ e \end{bmatrix} \\ W &= W \\ S &= S \\ D &= D \end{aligned}
}
\EndFor
\State{
\begin{aligned}[t] a &=a \\ a &= a \end{aligned}
}
}
\EndFor

\end{algorithmic}
\end{algorithm}
\end{document}


• You get a better result if you increase \lineskip in the algorithm environment; try with \setlength{\lineskip}{3pt} just before the first \For to see what I mean. – egreg Sep 16 '14 at 10:34
• @egreg Thanks and I updated the answer accordingly. Thanks. – user11232 Sep 16 '14 at 10:55
• The big in line objects cause \lineskip glue instead of the normal \baselineskip glue, because this would result negative. The default value is 1pt, but in a case like this, giving more room seems better. The effect is clearly seen between lines 1 and 2, 2 and 3, 3 and 4. – egreg Sep 16 '14 at 10:58