# 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

<--> <->

• Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. - Related: tex.stackexchange.com/a/32981/124842, tex.stackexchange.com/q/40535/124842 Oct 15, 2017 at 11:01

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? Oct 19, 2017 at 13:49
• Outside of the matrix, on the right. Just like if You flip matrix from your answer 90 degrees counter clockwise. Oct 19, 2017 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"). Oct 19, 2017 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. Oct 19, 2017 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) Jan 3, 2021 at 9:43
• @Zarko: Yes, you are right. I will modify the date. Happy new year. Jan 3, 2021 at 9:53