0

I am trying to align brackets inside of cases. This is my equation:

\begin{align}
y(x)=
\begin{cases}
  \bigg[ & 1+2 & \\
         & +5+6 \bigg] & \text{if } x < 2, \\
  \bigg[ & 11+12 & \\
        & +15+16 \bigg] & \text{if }x > 2,\\
        0 & & \text{otherwise.}
\end{cases} 
\end{align}

When I compile this, I get the following error

! Extra alignment tab has been changed to \cr.

The same happens when I remove the align environment change it to equation instead.

\begin{equation}
y(x)=
\begin{cases}
  \bigg[ & 1+2 & \\
        & +5+6 \bigg] & \text{if } x < 2, \\
  \bigg[ & 11+12 & \\
        & +15+16 \bigg] & \text{if }x > 2,\\
        0  & & \text{otherwise.}
\end{cases} 
\end{equation}

I searched for this problem, but all the questions seem to be about table environments.

  • 1
    I think you can only use a single alignment tab (&) per case. When I delete the second & in each case, the error goes away. – NickD Mar 11 '17 at 3:14
  • Right, it works that way. I was wondering if its possible to align brackets inside my multiline cases to make it easier to understand which brackets pair up. – highBandWidth Mar 11 '17 at 3:21
  • Please complete your code so it produces the error you report. Right now it obviously will not get that far. – cfr Mar 11 '17 at 4:39
1

Nick has explained by this doesn't work. Two possible workarounds are shown below, one using array instead of cases, the other using a multlined (requires the mathtools package) inside cases.

And note that for single equations you should be using equation, not align (align vs equation).

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
y(x)= \left\{
\begin{array}{@{\,}r@{}ll}
  \biggl[ & 1+2 & \\
        & +5+6 \biggr] & \text{if } x < 2, \\
  \biggl[ & 11+12 & \\
        & +15+16 \biggr] & \text{if }x > 2,\\
        0  & & \text{otherwise.}
\end{array}\right.
\end{equation}

\begin{equation}
y(x)=
\begin{cases}
  \begin{multlined}[b]
   \bigg[1+2  \\
        +5+6 \bigg]
\end{multlined} & \text{if } x < 2, \\
  \begin{multlined}[b]
\bigg[11+12  \\
        +15+16 \bigg]
\end{multlined} & \text{if }x > 2,\\
        0  &  \text{otherwise.}
\end{cases} 
\end{equation}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.