# nested arrays spacing

I'm trying to align two child arrays to a parent array. At the moment my code gives:

Which means, the two child arrays refer only to first row and fourth row of parent array. I would like the curly braces to be centered at row 2 and in the middle of row4 and row5, possibly being aligned with the respective parent rows.

\documentclass{article}

\usepackage{amsmath}
\begin{document}

$$\qquad\textbf{b)}\left\{ \begin{array}{l} a_{11}x_1+a_{12}x_1+a_{13}x_3+a_{14}x_{4}=b_1 \left\{ { \begin{array}{l} a_{11}z_1+a_{12}z_2+a_{13}z_3=r_1\\ a_{22}z_2=r_2\\ a_{31}x_1+a_{22}x_2+a_{33}x_3=r_3\\ \end{array} } \right.\\ a_{22}x_2=b_2\\ a_{31}x_1+a_{32}x_2+a_{33}x_3+a_{34}x_4=b_3\\ a_{42}a_2+a_{43}x_3+a_{44}x_4+a_{45}x_5=b_4 \left\{ { \begin{array}{l} a_{44}z_4+a_{45}z_5=r_4\\ a_{52}z_2+a_{53}z_3+a_{54}z_4+a_{55}z_5=r_5\\ \end{array} } \right.\\ a_{52}x_2+a_{53}x_3+a_{54}x_4+a_{55}x_5=b_5\\ \end{array} \right.$$

\end{document}

• Welcome to TeX.SX. When you post a question, please provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output. – Sandy G Mar 21 at 14:42

Here is an option using cases and \smash, with no arrays.

\documentclass{article}

\usepackage{amsmath}
\begin{document}

\begin{equation*}
a_{11}x_1+a_{12}x_1+a_{13}x_3+a_{14}x_{4}=b_1 & \\
a_{22}x_2=b_2 &\smash{\begin{cases}a_{11}z_1+a_{12}z_2+a_{13}z_3=r_1\\
a_{22}z_2=r_2\\
a_{31}x_1+a_{22}x_2+a_{33}x_3=r_3 \end{cases}}\\
a_{31}x_1+a_{32}x_2+a_{33}x_3+a_{34}x_4=b_3 & \\
a_{42}a_2+a_{43}x_3+a_{44}x_4+a_{45}x_5=b_4 & \\
a_{52}x_2+a_{53}x_3+a_{54}x_4+a_{55}x_5=b_5 & \raisebox{.5\normalbaselineskip}{$\smash{\begin{cases}a_{44}z_4+a_{45}z_5=r_4\\ a_{52}z_2+a_{53}z_3+a_{54}z_4+a_{55}z_5=r_5\end{cases}}$}
\end{cases}
\end{equation*}

\end{document}


Note that the second set of cases is slightly low to avoid the lower braces hitting the upper ones. If you want you can set the \raisebox to .632\normalbaselineskip to align the equations. But then you may want to lower the second set by adding additional space after the b_3. I like the way this looks:

a_{31}x_1+a_{32}x_2+a_{33}x_3+a_{34}x_4=b_3 & \.5\normalbaselineskip]  But I think a better way would be to use aligned. \begin{equation*} \textbf{b)}\left\{ \begin{aligned} a_{11}x_1+a_{12}x_1+a_{13}x_3+a_{14}x_{4}&=b_1\\ a_{22}x_2&=b_2\\ a_{31}x_1+a_{32}x_2+a_{33}x_3+a_{34}x_4&=b_3\\ a_{42}a_2+a_{43}x_3+a_{44}x_4+a_{45}x_5&=b_4\\ a_{52}x_2+a_{53}x_3+a_{54}x_4+a_{55}x_5&=b_5\\ \end{aligned} \right.\hspace{-1em} \begin{tabular}{c} \left\}\hspace{-.5em}\phantom{\begin{aligned}&b_1\\&b_2\\&b_3\\ \end{aligned}}\right\{\\ \left\}\hspace{-.5em}\phantom{\begin{aligned}&b_1\\&b_2\\ \end{aligned}}\right\{ \end{tabular} \hspace{-.75em}\begin{aligned} r_1&=a_{11}z_1+a_{12}z_2+a_{13}z_3\\ r_2&=a_{22}z_2\\ r_3&=a_{31}x_1+a_{22}x_2+a_{33}x_3\\ r_4&=a_{44}z_4+a_{45}z_5\\ r_5&=a_{52}z_2+a_{53}z_3+a_{54}z_4+a_{55}z_5 \end{aligned} \end{equation*}  It requires a \phantom tabular in the middle to get the braces aligned. You can set the space between the braces by adjusting the \hspace{-.5em} in two places. Here is a proposal \documentclass{article} \usepackage{geometry} \usepackage{amsmath} \begin{document} \[ \begin{cases} \begin{array}{@{}l@{}} a_{11}x_1+a_{12}x_1+a_{13}x_3+a_{14}x_{4}=b_1\\ a_{22}x_2=b_2\\ a_{31}x_1+a_{32}x_2+a_{33}x_3+a_{34}x_4=b_3 \end{array}\begin{cases} a_{11}z_1+a_{12}z_2+a_{13}z_3=r_1\\ a_{22}z_2=r_2\\ a_{31}x_1+a_{22}x_2+a_{33}x_3=r_3 \end{cases}\\[20pt] \begin{array}{@{}l@{}} a_{42}a_2+a_{43}x_3+a_{44}x_4+a_{45}x_5=b_4\\ a_{52}x_2+a_{53}x_3+a_{54}x_4+a_{55}x_5=b_5 \end{array}\begin{cases} a_{44}z_4+a_{45}z_5=r_4\\ a_{52}z_2+a_{53}z_3+a_{54}z_4+a_{55}z_5=r_5 \end{cases} \end{cases}
\end{document}