# Aligning material of two or more cases environment

The following code

 \documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
a=&
\begin{cases}
b,&\ \text{if}\ c\,;\\
d,&\ \text{if}\ e\,;\\
f,&\ \text{otherwise}\,.
\end{cases}\\[3mm]
g=&
\begin{cases}
h,&\ \text{if}\ i\,;\\
j,&\ \text{if}\ k\,;\\
l,&\ \text{otherwise}\,,
\end{cases}
\end{align*}
\end{document}


yields

What I really want is to align the clauses of the two sets of cases as well, that is, I want something like this, including the two left braces (which, of course, are missing; otherwise I wouldn't be asking):

By the way, the code for the "aligned but without braces" example above is the following:

 \documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\begin{aligned}
&\ \ bbbb,\ & &\text{if}\ c\,;\\
a=&\ \ dd,\ & &\text{if}\ e\,;\\
&\ \ fffff,\ & &\text{otherwise}\,.\\[3mm]
&\ \ h,\ & &\text{if}\ i\,;\\
g=&\ \ jjjjjjjjj,\ & &\text{if}\ k\,;\\
&\ \ l,\ & &\text{otherwise}\,,
\end{aligned}
\end{equation*}
\end{document}


I tried to introduce \left\{ (resp. \right) at the most natural places, namely, right before "bbbb" and "h" (resp. right after the two instances of "otherwise."), without success.

If you know the longest entry, a solution may be as follows:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\newlength{\myjjj}
\begin{equation*}
\settowidth{\myjjj}{$jjjjjjjjj,$} %longest entry
\begin{aligned}
&
a=\begin{cases}
\makebox[\myjjj][l]{$bbbb,$}\ &\text{if}\ c\,;\\
dd,\ &\text{if}\ e\,;\\
fffff,\ &\text{otherwise}\,.\\[3mm]
\end{cases}\\
&g=\begin{cases}
h,\  &\text{if}\ i\,;\\
jjjjjjjjj,\  &\text{if}\ k\,;\\
l,\ & \text{otherwise}\,,
\end{cases}
\end{aligned}
\end{equation*}
\end{document}


• Btw mathtools have a mathmakebox, then you do not need to wrap the contents in dollars – daleif May 23 '16 at 7:40