3

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.

6
  • How or where is \Scale defined? Commented Sep 4, 2021 at 17:06
  • Your code does not compile. Anyway, have you tried to change \arraystretch? Commented Sep 4, 2021 at 17:08
  • To get the extra vertical line segment, change \multicolumn{3}{c}{...} to \multicolumn{3}{c|}{...}. Commented Sep 4, 2021 at 17:12
  • @JuanCastano I don't know \arraystretch Commented Sep 4, 2021 at 17:16
  • Take a look at this post: tex.stackexchange.com/questions/564125/where-is-arraystretch. Commented Sep 4, 2021 at 17:18

4 Answers 4

4

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}
2
  • Thank you @Mico. If I'd like to space only this array, how must I do? And then, the horizzontal dashed line? Thnak you again Commented Sep 4, 2021 at 20:33
  • @Puck - To limit the scope of the \renewcommand\arraystretch{1.5} directive to just this particular equation environment, place a \begingroup instruction right before \renewcommand\arraystretch{1.5} and an \endgroup instruction immediately after \end{equation}. I'm afraid I don't know what you're referring to with "the horizzontal dashed line". Please elaborate. Commented Sep 4, 2021 at 21:20
4

An alternative solution with tblr environment of the new LaTeX3 package tabularray:

\documentclass{book}
\usepackage{mathtools}
\usepackage{stix}

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

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

\usepackage{tabularray}
\SetTblrInner{rowsep=4pt}

\begin{document}

\begin{equation}\label{A_MEG_Blocchi}
A^{(\:\:)} \coloneqq
\Tonde{
  \begin{tblr}{c|c}
    \SetCell[c=2]{c} & \\
    \cline{2-2}
    \phantom{K} & K % <-- '\phantom{K}' is new
  \end{tblr}}
=
\Tonde{
  \begin{tblr}{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)} \\
    \cline[dashed]{1-3}\cline{4-6}
    \SetCell[r=3,c=3]{c}\Scale[4]{$0$} & &
    &a_{kk}^{(k)} & \cdots & a_{kn}^{(k)} \\
    & & & \vdots&\ddots&\vdots\\
    &&&a_{nk}^{(k)}&\cdots&a_{k+1,n}^{(k)}
  \end{tblr}}
\end{equation}

\end{document}

enter image description here

1
  • Thank you @LJR, never seen this tblr-environment. I think that your great solution will be useful for me in order to substitute other particular array-environment. Thank you so much again Commented Sep 5, 2021 at 7:46
2

Here is what I would do with {pNiceArray} of nicematrix.

\documentclass{book}
\usepackage{mathtools,stix}
\usepackage{nicematrix,tikz}

\begin{document}

\begin{equation}\label{A_MEG_Blocchi}
\renewcommand{\arraystretch}{1.6}
A^{(\:\:)} \coloneqq
\begin{pNiceMatrix}[margin=3pt,columns-width=5mm]
  \\
  & K 
\CodeAfter
  \tikz \draw (3-|2) |- (2-|3) ;
\end{pNiceMatrix}
=
\begin{pNiceMatrix}[margin=3pt,xdots/line-style=dotted,xdots/shorten=1pt]
  a_{11}^{(1)}&\Cdots&&&&a_{1n}^{(1)} \\
  0&\Ddots&&&&\Vdots \\
  0&0&a_{k-1,k-1}^{(k-1)}&&\Cdots&a_{k-1,n}^{(k-1)} \\
  \Block{3-3}<\Huge>{$0$} &  &  &a_{kk}^{(k)} & \Cdots & a_{kn}^{(k)} \\
  & & & \Vdots&\Ddots&\Vdots\\
  &&&a_{nk}^{(k)}&\Cdots&a_{k+1,n}^{(k)}
\CodeAfter
  \line{2-1}{3-1}
  \line{2-1}{3-2}
  \line{3-1}{3-2}
  \begin{tikzpicture}
    \draw (1-|4) -- (last-|4) (4-|4) -- (4-|last) ; 
    \draw [dashed] (4-|1) -- (4-|4) ;
  \end{tikzpicture}
\end{pNiceMatrix}
\end{equation}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

1

I solved my problem so:

\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{\begingroup{
  \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}
    0&\cdots&0&a_{kk}^{(k)} & \cdots & a_{kn}^{(k)} \\[-7.5mm] \hdotsfor[0.75]{3}\\[-2.5mm]
    \multicolumn{3}{c|}{\multirow{3}{*}{\Scale[4]{$0$}}}
    &\vdots&\ddots&\vdots\\
    &&&a_{nk}^{(k)}&\cdots&a_{k+1,n}^{(k)}
  \end{array}}\endgroup}
\end{equation}

Thank you Mico!

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.