Aligned environment: How to align equations in the ‘left column’ and align conditions/words in the ‘right column’

alignhorizontal alignmentmath-mode

I have a list of boundary conditions which I would like to display using aligned environment. Here is the code so far:

\begin{equation}
\left.\begin{aligned}
x&=y &\text{in...},\\\
x'&=y'  &\text{in...}, \\\
x''&=y''&\text{in...}, \\\
x'''&=y'''&\text{in....}\\\
\end{aligned}\right\}
\end{equation} 

I want the equations on the LHS to be aligned at the = sign, but I also want the start of each condition (in...) to be aligned at in. Does anyone know how I can do this?

Best Answer

You need an additional & to switch the alignment:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}
  \left.\begin{aligned}
       x &= y    &&\text{in $a$},               \\
      x' &= y'   &&\text{in $a$, $b$},          \\
     x'' &= y''  &&\text{in $a$, $b$, $c$},     \\
    x''' &= y''' &&\text{in $a$, $b$, $c$, $d$}
  \end{aligned}\right\}
\end{equation}

\end{document}
Related Question