# Using \align inside \cases

The code I was using is this:

        $\begin{cases} W_n(\mathcal{O}_k) =\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): x_i\in \mathcal{O}_k,\text{ } i\in{\{0,1,\cdots, n-1\}} \}\\ W_n(m_k)=\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k) :x_i\in m_k,\text{ } i\in{\{0,1,\cdots, n-1\}}\} \\ W_n(m_k)^{(m)}= \{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): v(x_i)\geq m/p^{n-1-i},\text{ } i\in{\{0,1,\cdots, n-1\}} \} \end{cases}$


which worked fine, but when I changed my spacing and all this the third equation ended up being too long meaning I had to change something. I went for the most naive option to just split the definition of the set \{W_n(m_k)^{(m)} by simply doing this

W_n(m_k)^{(m)}=
\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): \\
v(x_i)\geq m/p^{n-1-i},\text{ } i\in{\{0,1,\cdots, n-1\}} \}


but at least I should align the two lines of definition.

How could I do this? (I tried using \align, \aligned but it seems it doesn't work with cases.

Or would there be a 'better' way of writing a set in two lines?

You mean something like this?

$\begin{cases} W_n(\mathcal{O}_k) = \{X^{(n)} = (x_0, x_1, \cdots, x_{n-1}) \in W_n(k): x_i \in \mathcal{O}_k,\text{ } i \in{\{0, 1, \cdots, n-1\}} \}\\ W_n(m_k) = \{X^{(n)} = (x_0, x_1, \cdots, x_{n-1}) \in W_n(k): x_i \in m_k,\text{ } i \in{\{0, 1, \cdots, n-1\}}\} \\ W_n(m_k)^{(m)} = \{X^{(n)} = (x_0, x_1, \cdots, x_{n-1}) \in W_n(k): \\ \hphantom{W_n(m_k)^{(m)} = \strut}v(x_i) \geq m/p^{n-1-i},\text{ } i \in{\{0, 1, \cdots, n-1\}} \} \end{cases}$


\hphantom reserves horizontal space, and the \strut is just a random trick to add the “after equal sign spacing”. It's not a very pretty solution, though. On a side-note: adding spaces in your equations should make them easier to work with. They are generally ignored during compilation in maths, so it's convenient to make the code prettier. You can even add linebreaks! ♥ You might also want to consider using something like \quad, \enspace or one of the various math spaces instead of \text{ }.

You might be able to write another solution using array and a solitary huge left curly brace in place of the cases. Try the following dumb example to see what I mean:

$\left\{ \begin{array}{@{} r l @{}} x &= 1 \\ \mathit{plop} &= 2 \end{array} \right.$


I don't have the time to do it myself right now, though. Sorry.

I would align at the = signs and the third equation is split so that the \geq operator is aligned to the = above. I changed also a couple of things; the outer delimiters are changed to \bigl\{ and \bigr\} and the \cdots are changed to \dotsc, which means dots between commas.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}

\begin{cases} \begin{aligned} W_n(\mathcal{O}_k) &=\bigl\{X^{(n)}=(x_0,x_1,\dotsc,x_{n-1})\in W_n(k): x_i\in \mathcal{O}_k,\, i \in{\{0,1,\dotsc, n-1\}}\bigr\}\\ W_n(m_k) &=\bigl\{X^{(n)}=(x_0,x_1,\dotsc,x_{n-1})\in W_n(k): x_i\in m_k,\, i\in{\{0,1,\dotsc, n-1\}}\bigr\} \\ W_n(m_k)^{(m)} &=\begin{aligned}[t]\bigl\{X^{(n)} &=(x_0,x_1,\dotsc,x_{n-1})\in W_n(k): \\ v(x_i) &\geq m/p^{n-1-i},\, i\in{\{0,1,\dotsc, n-1\}} \bigr\} \end{aligned} \end{aligned} \end{cases}

\end{document}


LaTeX offers lot of possibilities. Here is another solution.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$\begin{cases} W_n(\mathcal{O}_k) = \bigl\{ X^{(n)}= (x_0, x_1, \dotsc, x_{n-1}) \in W_n(k) \mid x_i \in \mathcal{O}_k,\ 0 \le i \le n-1 \bigl\}\\ W_n(m_k) = \bigl\{ X^{(n)}= (x_0, x_1, \dotsc, x_{n-1}) \in W_n(k) \mid x_i\in m_k,\ 0 \le i \le n-1 \bigl\}\\ W_n(m_k)^{(m)} = \bigl\{ X^{(n)} = (x_0, x_1, \dotsc, x_{n-1}) \in W_n(k) \mid {}\\[-2pt] \hfill v(x_i)\geq m/p^{n-1-i},\ 0 \le i\le n-1 \bigl\} \end{cases}$

\end{document}


I would use a matrix*[l] environment, or the empheq package and slightly change the layout:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{empheq}

\begin{document}

$\begin{cases} W_n(\mathcal{O}_k) =\bigl\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): x_i\in \mathcal{O}_k,\text{ } i\in \{0,1,\cdots, n-1\}\bigr \}\\[1ex] W_n(m_k)=\bigl\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k) :x_i\in m_k,\text{ } i\in \{0,1,\cdots, n-1\} \bigr\} \\[1ex] W_n(m_k)^{(m)}= \biggl\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): \:\Bigm\vert \begin{matrix*}[l]v(x_i)\geq m/p^{n-1-i},\text{ }\\[-0.5ex] i\in\{0,1,\cdots, n-1\}\end{matrix*}\biggr \} \end{cases}$

\begin{empheq}[left=\empheqlbrace\,, right ={\qquad( i\in \{0,1,\cdots, n-1\})} ]{align*}
& W_n(\mathcal{O}_k) =\bigl\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): x_i\in \mathcal{O}_k \}\bigr \}\\[1ex]
& W_n(m_k)=\bigl\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k) :x_i\in m_k \bigr\} \\[1ex]
& W_n(m_k)^{(m)} = \Bigl\{X^{(n)}=(x_0,x_1,\cdots,x_{n-1})\in W_n(k): v(x_i)\geq m/p^{n-1-i} \Bigr \}
\end{empheq}

\end{document}