# Vertical Alignment of Matrix Cells

In the equation below, I would like to have the horizontal dashed lines that seperate different cells of the matrix to be vertically aligned. Furthermore it would be nice if the square brackets of both matrices would have the same height.

Any suggestions?

PS: The only way to include the extra vectors including the triple dots I figured out was the attached combination of array / matrix environments. Is there a more elegant way to do this? PSS: I am using TexStudio. Is there a similar "automatically align marked code"-function as in Matlab's "Ctrl+I"?

\documentclass{article}
\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}

$$\left[\begin{array}{c} \begin{matrix} x\\ \vdots\\ x \\ \end{matrix} \\ \hdashline 0 \\ \hdashline \begin{matrix} x\\ \vdots\\ x \\ \end{matrix} \\ \end{array}\right] = \left[\begin{array}{c:c} 0 & 0 \\ \hdashline 0 & \underbrace{\bar{X}_{11}}_{\bar{X}_{22}} \\ \hdashline 0 & 0 \\ \end{array}\right]$$

\end{document}


\vphantom can calculate the height:

\documentclass{article}
\usepackage{amsmath}
\usepackage{arydshln}

\begin{document}

$\begin{bmatrix} ~x~\\ \vdots\\ x \\ \hdashline \vphantom{\overbrace{\bar{X}_1}^{\bar{X}_2}\underbrace{\bar{X}_1}_{\bar{X}_2}} 0 \\ \hdashline x\\ \vdots\\ x \end{bmatrix} = \left[ \begin{array}{c:c} \phantom{x}\\ \vphantom{\vdots}0 & 0\\ \phantom{x}\\ \hdashline 0 & \vphantom{\overbrace{\bar{X}_1}^{\bar{X}_2}} \underbrace{\bar{X}_{11}}_{\bar{X}_{22}} \\ \hdashline \phantom{x}\\ \vphantom{\vdots}0 & 0\\ \phantom{x} \end{array}\right]$

\end{document}


With this, I just used a few \mboxes with struts made from extended \rules.

\documentclass{article}
\usepackage{amsmath} % Paket für Mathematische Formeln
\usepackage{arydshln}
\def\mystrutbox#1{\mbox{$#1$\rule[-4ex]{0ex}{10ex}}}
\begin{document}
$\left[\begin{array}{c} \begin{matrix} x\\ \vdots\\ x \\ \end{matrix} \\ \hdashline \mystrutbox{0} \\ \hdashline \begin{matrix} x\\ \vdots\\ x \\ \end{matrix} \\ \end{array}\right] = \left[\begin{array}{c:c} \,~\mystrutbox{0}~\, & 0 \\ \hdashline \mystrutbox{0} & \underbrace{\bar{X}_{11}}_{\bar{X}_{22}} \\ \hdashline \mystrutbox{0} & 0 \\ \end{array}\right]$
\end{document}