# LaTeX array and matrix equal spacing

I'm trying to make a matrix with block 0s (so I don't have to write out the zeros). This is what I have

 % Taken from https://tex.stackexchange.com/questions/323297/typing-block-matrices-with-zero-blocks-and-seperators
\newcommand{\bigzero}{\mbox{\normalfont\Large\bfseries 0}}

$$\begin{bmatrix} \begin{array}{c|c|c} \bigzero_{4\times 4} & \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ \end{matrix} & \begin{matrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \\ \hline \bigzero_{4\times 4} & \begin{matrix} X_u & X_w & X_q & -\cos(\theta_1) \\ Z_u & Z_w & Z_q & \substack{-\sin(\theta_1)\\\times\cos(\phi_1)} \\ M_u & M_w & M_q & 0 \\ 0 & 0 & \cos(\phi_1) & 0 \\ \end{matrix} & \begin{matrix} X_v & X_p & X_r & 0 \\ Z_v & Z_p & Z_r & \substack{-\cos(\theta_1)\\\times\sin(\phi_1)} \\ M_v & M_p & M_r & 0 \\ 0 & 0 & -\sin(\phi_1) & \substack{-q_1\sin(\phi_1) \\- r_1\cos(\phi_1)} \\ \end{matrix} \\ \hline \bigzero_{4\times 4} & \begin{matrix} Y_u & Y_w & Y_q & \substack{-\sin(\phi_1)\\\sin(\theta_1)} \\ L_u & L_w & L_q & 0 \\ N_u & N_w & N_q & 0 \\ 0 & 0 & \substack{\sin(\phi_1)\\\times\tan(\theta_1)} & \substack{\substack{(q_1\sin(\phi_1) \\+ r_1\cos(\phi_1))}\\\times\sec^2(\theta_1)} \\ \end{matrix} & \begin{matrix} Y_v & Y_p & Y_r & \substack{\cos(\phi_1)\\\cos(\theta_1)} \\ L_v & L_p & L_r & 0 \\ N_v & N_p & N_r & 0 \\ 0 & 1 & \substack{\cos(\phi_1)\\\times\tan(\theta_1)} & \substack{\substack{(q_1\cos(\phi_1)\\- r_1\sin(\phi_1))}\\\times\tan(\theta_1)} \\ \end{matrix} \end{array} \end{bmatrix}$$


The result looks like this:

Is there a way to get all the terms to line up, instead of the first columns being smaller than the subsequent columns? All the answers I've seen so far only deal with matrices, but not matrices nested in an array

## 1 Answer

Ahh I ended up getting a solution with nicearray

\underbrace{\begin{bNiceArray}{cccc|cccc|cccc}[cell-space-limits = 4pt]
\Block{4-4}<\Large>{0_{4\times 4}} & & & & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
& & & & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
& & & & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
& & & & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\hline
\Block{4-4}<\Large>{0_{4\times 4}} & & & & X_u & X_w & X_q & -\cos(\theta_1) & X_v & X_p & X_r & 0 \\
& & & & Z_u & Z_w & Z_q & \substack{-\sin(\theta_1)\\\times\cos(\phi_1)} & Z_v & Z_p & Z_r & \substack{-\cos(\theta_1)\\\times\sin(\phi_1)} \\
& & & & M_u & M_w & M_q & 0 & M_v & M_p & M_r & 0 \\
& & & & 0 & 0 & \cos(\phi_1) & 0 & 0 & 0 & -\sin(\phi_1) & \substack{-q_1\sin(\phi_1) \\- r_1\cos(\phi_1)} \\\hline
\Block{4-4}<\Large>{0_{4\times 4}} & & & & Y_u & Y_w & Y_q & \substack{-\sin(\phi_1)\\\sin(\theta_1)} & Y_v & Y_p & Y_r & \substack{\cos(\phi_1)\\\cos(\theta_1)} \\
& & & & L_u & L_w & L_q & 0 & L_v & L_p & L_r & 0 \\
& & & & N_u & N_w & N_q & 0 & N_v & N_p & N_r & 0 \\
& & & & 0 & 0 & \substack{\sin(\phi_1)\\\times\tan(\theta_1)} & \substack{\substack{(q_1\sin(\phi_1) \\+ r_1\cos(\phi_1))}\\\times\sec^2(\theta_1)} & 0 & 1 & \substack{\cos(\phi_1)\\\times\tan(\theta_1)} & \substack{\substack{(q_1\cos(\phi_1)\\- r_1\sin(\phi_1))}\\\times\tan(\theta_1)}
\end{bNiceArray}}_{A_c}