Arrows describing matrix

Lets say I have a 5x5 matrix. I want to place 2 leftrightarrows (with descriptions "3", "2") underneath the matrix, but really close to it: first pointing from col1 to col3 and second from col4 to col5. Plus updownarrows with similar outcome. How can I achieve that?

draft:

1 1 1 | 1 1

<--> <->

matrix is drawn ... :-)

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{arrows.meta, matrix, quotes, positioning}

\begin{document}
\begin{tikzpicture}[LA/.style = {Straight Barb-Straight Barb,
shorten <=1pt, shorten >=1pt,
draw=red}
]
\matrix (m) [matrix of math nodes,
left  delimiter={[},
right delimiter={]}
]
{
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
};
\draw (m-1-3.north east) -- (m-5-3.south east);
\draw (m-4-1.north west) -- (m-4-5.north east);
%
\draw[LA] (m-5-1.south west |- m.south) to ["3" '] (m-5-3.south east |- m.south);
\draw[LA] (m-5-4.south west |- m.south) to ["2" '] (m-5-5.south east |- m.south);
%
\coordinate[right=5mm of m.east] (e);
\draw[LA] (m-1-5.north east -| e) to ["3"] (m-3-5.south east -| e);
\draw[LA] (m-4-5.north east -| e) to ["2"] (m-5-5.south east -| e);
\end{tikzpicture}
\end{document}

• Thank You, it's exactly what I wanted :) But still I'm struggling with updownarrows on the right of matrix. Could you recomend me a book or script with documentation about matrix and arrows in tikz? – Lucas Oct 19 '17 at 13:49
• @Lucas, where should be this arrows? your question is not clear about this. i only figured out these in my answer. – Zarko Oct 19 '17 at 13:53
• Outside of the matrix, on the right. Just like if You flip matrix from your answer 90 degrees counter clockwise. – Lucas Oct 19 '17 at 13:57
• Something like this, but with straight updownarrow: tex.stackexchange.com/questions/340919/… And I want to make 2 arrows, just like last time (values "3" and "2"). – Lucas Oct 19 '17 at 14:07
• I wrote "Lets say I have a 5x5 matrix." at the begining of the question, but true, I should include sketch and I will. – Lucas Oct 19 '17 at 14:32

Here is what you can do with the latest version of nicematrix (v. 5.8 2021-01-01).

\documentclass{article}

\usepackage{nicematrix}
\usepackage{tikz}

\tikzset{H/.style = {solid,<->}}
\tikzset{V/.style = {solid,<->,xshift=2mm}}

\begin{document}

$\begin{pNiceArray}{ccc|cc}[first-row,last-col] \Hdotsfor[line-style=H]{3}^{3} & \Hdotsfor[line-style=H]{2}^{2} \\ 1 & 1 & 1 & 1 & 1 & \Vdotsfor[line-style=V]{3}^{3}\\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ \hline 1 & 1 & 1 & 1 & 1 & \Vdotsfor[line-style=V]{2}^{2}\\ 1 & 1 & 1 & 1 & 1 \\ \end{pNiceArray}$

\end{document}


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

• Happy and prosper new year! I believe that v 5.8 if from this year: 20201? If so, you start to work in the very first day :-) ... (+1) – Zarko Jan 3 at 9:43
• @Zarko: Yes, you are right. I will modify the date. Happy new year. – F. Pantigny Jan 3 at 9:53