3

Consider the following matrix : enter image description here

I have no problem in constructing the matrix and I have no problem in circling the first and the fifth row, but I have no idea how to insert these arrows outside this matrix. I hope someone can help me out.

Here is what I wrote :

\documentclass[12pt,english]{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{nicematrix}
\begin{document}
$$
\begin{bNiceMatrix}%
[code-after = { \tikz \node [draw, rounded corners, fit = (5-1) (5-7)] { };  \tikz \node [draw, rounded corners, fit = (1-1) (1-7)] { } ;},  left-margin = 7pt, right-margin = 7pt] 
 0 & 0 & 0 & 0 & 1 & \cdots & 0 \\
 0 & 1 & 0 & 0 & 0 & \cdots & 0 \\
0 & 0 & \ddots & 0 & 0 & \cdots & 0 \\
0 & 0 & 0 & 1 & 0 & \cdots & 0 \\
1 & 0 & 0 & 0 & 0 & \cdots & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 1
\end{bNiceMatrix}
$$
\end{document}
New contributor
user232914 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Welcome to the TeX.SE. There are nicematrix, kbordermatrix and other options. Please, can you put your complete code of your work? – Sebastiano 2 days ago
  • Does this answer your question? Highlight elements in the matrix – Werner 2 days ago
  • Hello. no since my concern is how to add the arrows on the right of the matrix. – user232914 2 days ago
  • 1
    Final update of my code is now completed, now to return to my main concern on how to draw these arrows. – user232914 2 days ago
1

You wrote,

my concern is how to add the arrows on the right of the matrix.

Your objective may be achieved easily by adding a one-column, left-aligned array environment.

enter image description here

\documentclass[12pt,english]{article}
\usepackage{amsmath}
\usepackage{old-arrows} % optional (for smaller arrowheads)
\begin{document}
\[
\begin{bmatrix}
0 & 0 & 0 & 0 & 1 & \cdots & 0 \\
0 & 1 & 0 & 0 & 0 & \cdots & 0 \\
0 & 0 & \smash{\ddots} & 0 & 0 & \cdots & 0 \\
0 & 0 & 0 & 1 & 0 & \cdots & 0 \\
1 & 0 & 0 & 0 & 0 & \cdots & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 1
\end{bmatrix}
\begin{array}{l}
\gets 1 \\
\gets 2 \\
\smash{\vdots} \\
\gets i_1-1 \\
\gets i_1 \\
\smash{\vdots} \\
\gets n
\end{array}
\]
\end{document}
  • Interesting approach, thank you very much! – user232914 2 days ago
2

Use last-col:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{nicematrix}

\begin{document}

\[
\begin{bNiceMatrix}[
  code-after = {
   \tikz \node [draw, rounded corners, fit = (5-1) (5-7)] { };
   \tikz \node [draw, rounded corners, fit = (1-1) (1-7)] { } ;
  },
  left-margin = 7pt,
  right-margin = 7pt,
  last-col,
] 
0 & 0 & 0 & 0 & 1 & \cdots & 0 & \leftarrow 1\\
0 & 1 & 0 & 0 & 0 & \cdots & 0 & \leftarrow 2\\
0 & 0 & \smash{\ddots} & 0 & 0 & \cdots & 0 & \smash{\vdots} \\
0 & 0 & 0 & 1 & 0 & \cdots & 0 & \leftarrow i_1-1 \\
1 & 0 & 0 & 0 & 0 & \cdots & 0 & \leftarrow i_1 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 & \smash{\vdots} \\
0 & 0 & 0 & 0 & 0 & 0 & 1 & \leftarrow n
\end{bNiceMatrix}
\]

\end{document}

enter image description here

  • Thank you very much! your answer is much appreciated. – user232914 2 days ago

Your Answer

user232914 is a new contributor. Be nice, and check out our Code of Conduct.

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.