# mathtools: cases inside alignment

Hi. I have struggled with aligning with cases environment The minimal example of the above thing is the following:

\documentclass{article}
\usepackage{mathtools}

\makeatletter
\hfil$\m@th\displaystyle{##}$}{{##}\hfil}{\lbrace}{.}
\makeatother

\begin{document}
$\begin{PDEcases} -\triangle u +u \cdot \nabla u +\nabla p =f&in \Omega\\ \mathrm{div}\, u =0& in \Omega\\ u=0& on \partial \Omega, \end{PDEcases}$

Alignment inside cases

$\begin{dcases*} -\triangle u +\nabla p =-w\cdot \nabla w +f&in \Omega\\ \hspace{2.75em}\mathrm{div}\, u =0& in \Omega\\ \hspace{4.2em}u=0& on \partial \Omega, \end{dcases*}$
\end{document}


For the first case, using \newcases, I can easily make a custom environment on cases. But I want to make an equation like second form. But I failed to make an equation with cases environment. I manually adjust it by using \hspace.

How can I make it more smarter way?

One possible solution of mine is to use the alignedat enviornment. But it is not a case environment.

Here is a code:

\left\{ \begin{alignedat}{2} -\triangle u +\nabla p &=-w\cdot \nabla w +f&&\qquad \mbox{in \Omega},\\ \mathrm{div}\, u &=0&&\qquad \mbox{in \Omega},\\ u&=0 &&\qquad \mbox{on \partial \Omega}, \end{alignedat} \right.


I'm unsatisfied with \quad part and \left\{ \right. Is there anyway to make it using cases stuff?

Here is a solution with cases. I've added another solution, which has a better vertical spacing, in my opinion, and a shorter code, with the empheq package (which loads mathtools).

Also I replaced \triangle with the more correct Delta, and defined div as a Math Operator:

\documentclass{article}
\usepackage{empheq}

\DeclareMathOperator{\Div}{div}
\begin{document}

\begin{dcases} \begin{aligned} -\Delta u +\nabla p & =-w\cdot \nabla w +f \\ \Div u & =0 \\ u & =0 \end{aligned} & \begin{aligned} & \text{in } \Omega, \\ & \text{in } \Omega, \\ & \text{on }\partial \Omega. \end{aligned} \end{dcases}
\bigskip

\begin{empheq}[left = \empheqlbrace]{alignat* = 2}
-\Delta u +\nabla p & =-w\cdot \nabla w +f &\quad & \text{in } \Omega, \\
\Div u & = 0&\quad & \text{in } \Omega, \\
u & =0 & & \text{on }\partial \Omega.
\end{empheq}

\end{document}


• Actually, my society denote Laplacian by \triangle. Thanks! This is really nice. – Will Kwon Dec 28 '17 at 11:40

You can use aligned inside cases, but I'd prefer not to align at the equals signs.

\documentclass{article}
\usepackage{mathtools}
\DeclareMathOperator{\Div}{div}

\begin{document}

With alignment at the equals sign:
\begin{cases} \begin{aligned} -\triangle u +u \cdot \nabla u +\nabla p &= f && \text{in \Omega}, \\ \Div u &= 0 && \text{in \Omega}, \\ u &= 0 && \text{on \partial \Omega}, \end{aligned} \end{cases}

Without alignment:
$\begin{dcases*} -\triangle u +u \cdot \nabla u +\nabla p = f & in \Omega, \\ \Div u = 0 & in \Omega, \\ u = 0 & on \partial \Omega, \end{dcases*}$

\end{document}