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}
4
  • 1
    Welcome to the TeX.SE. There are nicematrix, kbordermatrix and other options. Please, can you put your complete code of your work? – Sebastiano Jan 13 at 21:37
  • Does this answer your question? Highlight elements in the matrix – Werner Jan 13 at 21:50
  • Hello. no since my concern is how to add the arrows on the right of the matrix. – user232914 Jan 13 at 21:53
  • 1
    Final update of my code is now completed, now to return to my main concern on how to draw these arrows. – user232914 Jan 13 at 22:13
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}
1
  • Interesting approach, thank you very much! – user232914 Jan 13 at 22:23
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

1
  • Thank you very much! your answer is much appreciated. – user232914 Jan 13 at 23:02

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.