Better \vspace{} and dashed line in array-environment

arraysvspace

In this code

\documentclass{book}
\usepackage{mathtools}
\usepackage{stix}
\usepackage{multicol,multirow}

\newcommand{\Tonde}[1]{\left(#1\right)}

\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand*{\Resize}[2]{\resizebox{#1}{!}{$#2$}}%

\begin{document}

\begin{equation}\label{A_MEG_Blocchi}
A^{(\:\:)}\coloneqq\Tonde{\begin{array}{c|c}\multicolumn{2}{c}{}\\\cline{2-2}&K\end{array}}=
\Tonde{\begin{array}{ccc|ccc}a_{11}^{(1)}&\cdots&\cdots&\cdots&\cdots&a_{1n}^{(1)}\\0&\ddots&\ddots&\cdots&\cdots&\vdots\\\vdots&\ddots&a_{k-1,k-1}^{(k-1)}&\cdots&\cdots&a_{k-1,n}^{(k-1)}\\[2mm]\cline{4-6}0&\cdots&0&a_{kk}^{(k)}&\cdots&a_{kn}^{(k)}\\[2mm]\multicolumn{3}{c}{\multirow{3}{*}{$\mathop{\Scale[5]{0}}$}}&\vdots&\ddots&\vdots\\&&&a_{nk}^{(k)}&\cdots&a_{k+1,n}^{(k)}\\[2mm]\end{array}}
\end{equation}

\end{document}

I'd like to have a better \vspace between the rows of this array and I'd like to add a horizzontal dash line between 4th and 5th rows (but only for three first coloumns) and why the vertical line is broken? Thank you so much.

Best Answer

Don't use \vspace to increase the separation between rows in an array. Instead, set \arraystretch to a number greater than 1. In the code below, I run \renewcommand\arraystretch{1.5}.

enter image description here

\documentclass{book}
\usepackage{mathtools} % for '\coloneqq' macro
\usepackage{stix}
\usepackage{multirow}
\newcommand{\Tonde}[1]{\left(#1\right)}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%

\begin{document}

\renewcommand\arraystretch{1.5} % <-- new

\begin{equation}\label{A_MEG_Blocchi}
A^{(\:\:)} \coloneqq
\Tonde{
  \begin{array}{c|c}
    \multicolumn{2}{c}{}\\
    \cline{2-2}
    \phantom{K} & K % <-- '\phantom{K}' is new
  \end{array}}
=
\Tonde{
  \begin{array}{ccc|ccc}
    a_{11}^{(1)}&\cdots&\cdots&\cdots&\cdots&a_{1n}^{(1)} \\
    0&\ddots&\ddots&\cdots&\cdots&\vdots \\
    \vdots&\ddots&a_{k-1,k-1}^{(k-1)}&\cdots&\cdots&a_{k-1,n}^{(k-1)} \\[1mm]
    \cline{4-6}
    \multicolumn{3}{c|}{\multirow{3}{*}{\Scale[4]{$0$}}}
    &a_{kk}^{(k)} & \cdots & a_{kn}^{(k)} \\
    & & & \vdots&\ddots&\vdots\\
    &&&a_{nk}^{(k)}&\cdots&a_{k+1,n}^{(k)}
  \end{array}}
\end{equation}

\end{document}