2

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

<--> <->

3

enter image description here

matrix is drawn ... :-)

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

\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.