I'm writing an algorithm that has an \begin{equation} inside it. I want the whole equation to be aligned to the left, as any typical text block would be aligned if written inside the algorithm environment.
The LaTeX code I'm currently working on is this:
\begin{algorithm}
\caption{Algorithm}
\label{alabel}
\KwData{
Lots of stuff written here.
}
\For{$i = 1, \ldots, n$} {
\If{something} {
do this
}
\Else {
do that
}
$\epsilon = $ simple equation
\If{$\epsilon < 0$} {
\begin{equation} %align me to the left
\begin{matrix}
\text{Choose } \theta \in
\left\{
\begin{array}{l l}
\left[f_k(x_i), f_k(x_{i+1}) \right) \text{ if } i < m\\
\left[f_k(x_m), +\infty \right) \text{ if } i = m\\
\end{array}
\right.\\
\end{matrix}
\end{equation}
An aditional step.
}
}
\Return the result
\end{algorithm}
I'm using algorithm2e and amsmath.