# Multiple alignemnt tabs within cases/equation environment

I am trying to align an equation within the cases environment like so:

\begin{equation}
R_i=
\begin{cases}
2G_{\frac{i}{2} - 1}  &= \frac{i^2 - 2i}{4}, & \text{if}\ 2 | i \\
2G_{\frac{i - 1}{2} - 1} + \frac{i-1}{2}  &= \frac{i^2 - 2i + 1}{4}, & \text{otherwise}.
\end{cases}
\end{equation}


Unfortunately this errors with

Extra alignment tab has been changed to \cr. [...\frac{i}{2} - 1} & = \frac{i^2 - 2i}{4}, &]

How would I go about having two alignment tabs in this case?

it works without the extra &

\begin{equation}
R_i=
\begin{cases}
2G_{\frac{i}{2} - 1}  = \frac{i^2 - 2i}{4}, & \text{if}\ 2 | i \\
2G_{\frac{i - 1}{2} - 1} + \frac{i-1}{2}  = \frac{i^2 - 2i + 1}{4}, & \text{otherwise}.
\end{cases}
\end{equation} • Do you really need alignment at =? Feb 1, 2018 at 16:27

You can use aligned or alignedat. But, in my opinion, a plain dcases (requires mathtools) is the best choice.

\documentclass{article}
\usepackage{amsmath,mathtools}

\begin{document}

\begin{equation}
R_i=
\begin{cases}
\begin{aligned}
2G_{\frac{i}{2} - 1}                   &= \frac{i^2-2i}{4},   && \text{if $2\mid i$}
\\
2G_{\frac{i-1}{2} - 1} + \frac{i-1}{2} &= \frac{i^2-2i+1}{4}, && \text{otherwise}.
\end{aligned}
\end{cases}
\end{equation}

\begin{equation}
R_i=
\begin{cases}
\begin{alignedat}{3}
&2G_{\frac{i}{2} - 1}                   &&= \frac{i^2-2i}{4},
&\quad& \text{if $2\mid i$}
\\
&2G_{\frac{i-1}{2} - 1} + \frac{i-1}{2} &&= \frac{i^2-2i+1}{4},
\end{alignedat}
\end{cases}
\end{equation}

\begin{equation}
R_i=
\begin{dcases}
2G_{\frac{i}{2} - 1} = \frac{i^2-2i}{4},                     & \text{if $2\mid i$}
\\
2G_{\frac{i-1}{2} - 1} + \frac{i-1}{2} = \frac{i^2-2i+1}{4}, & \text{otherwise}.
\end{dcases}
\end{equation}

\end{document} For divisibility, it's better to use 2\mid i rather than 2|i. I'd use \text{even $i$} and \text{odd $i$} instead.