# How to put a curly arrow beside a matrix

I did the following codes:

   \documentclass[tikz‎, ‎border=3mm]{standalone}‎
\usepackage{easybmat}‎
‎    \begin{document}‎‎
‎    $‎‎‎‎‎‎ \begin{array}{} ~\\ ‎ ~\\ ~\\ ‎ ~\\ ‎ ~ ~‎\\ ‎ ~\\‎ ‎ k‎‎\\ ‎ ~‎ \end{array}‎ ‎ \hspace*{-0.54cm}‎ \begin{array}{} ~\\ ‎ ~\\ ‎ ~\\ ‎ ~\\ ‎ ~ ‎ ‎‎i‎‎‎\\ ~\\ ‎ ~‎ \end{array}‎ ‎ \begin{array}{} \hspace*{1.5cm}‎\stackrel{j}{\downarrow}\\‎ ‎ \left( ‎ \begin{BMAT}{cccccc}{ccccc} *‎ & *‎‎ & *‎ & \cdots‎‎‎‎ & * & *‎ ‎‎‎‎‎\\ 0‎‎ & *‎‎ & *‎ & ‎\cdots‎‎ & * & ‎\vdots‎ ‎‎‎‎‎‎\\‎‎ ‎ \vdots‎ & 0‎‎ & 0‎ & a_{ij}‎‎ & \cdots &‎*‎ ‎‎‎‎‎‎‎\\‎‎ 0‎ & \cdots‎‎ & \fbox{‎‎a_{kj}‎‎}‎ & a_{k,j+1}‎‎ & \cdots & *‎‎‎‎‎‎\\‎‎ 0‎ & \cdots‎‎ & *& *‎‎ & \cdots & *‎ ‎‎‎‎‎ \addpath‎{(2,5,1)ddddd} \addpath{(3,5,1)ddddd}‎ \addpath{(0,1,1)rrrrrr}‎ \addpath{(0,2,1)rrrrrr}‎ \addpath{(0,3,1)rrrrrr} ‎ \end{BMAT} ‎ \right)‎‎‎‎‎ \end{array}‎ ‎ \hspace*{-0.1cm}‎ ‎‎‎‎ \begin{array}{} ~\\ ‎ ~\\ ~\\ ‎ ~\\ ‎ ~‎\\ ‎ ~\\ ‎ ~‎\\ ‎ ~‎‎ ‎‎ \leftarrow ‎k+1‎‎ \end{array}‎‎‎ ‎‎$‎
\end{document}‎


to have the certain matrix as below:

What could I do if an curly arrow is needed? I mean like this:

• sorry, where is curly braces? instead of arrow an the second image? Mar 13 '18 at 9:32
• @Zarko: I misused the word. I meant that vertical arc. Sorry. Mar 13 '18 at 10:10
• i'm sorry, but i do not understand what this upright arch is. where is it supposed to be? Mar 13 '18 at 10:14

I guess that the easybmat package provides an easy way to draw matrices like this. I don't know this package and instead recommend a matrix of math nodes using tikz. Using this gives something close to what you want:

The basic idea is that you put things into a "normal" latex matrix, with columns separated by &, and then you draw on the matrix using "normal" tikz. The nodes of the matrix are referred to (M-<row>-<col>), where row and col are the row and column indices. (The M is specified by the \matrix (M) [...]{...} in the code below -- if you want to use, for example, mat instead of M change (M) to (mat).) There are some complications to put your internal lines etc into place. Much of this is self-explanatory, but not everything, The box around the a_{kj} was the trickiest bit and I added some style to the delimiters as I thought that they were too big and too far away from the matrix. For more details see section 57 of the tikz manual. In the OP I was not sure if the the height of the third row should be higher than the other rows. If this is required then you can add something like

row 3/.style={minimum height=3em}


to the matrix style specifications: \matrix (M)[...style...]{...}.

Here is the full code:

\documentclass[border=10mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,calc}

\begin{document}

\begin{tikzpicture}[mline/.style={thin,gray},
boxed/.style={rectangle,minimum width=6mm,draw, text depth=0.5mm,
inner sep=0.7mm, text height=1ex},
every left delimiter/.style={xshift=.7em,scale=0.9},
every right delimiter/.style={xshift=-.7em,scale=0.9},
]
\matrix (M)[matrix of math nodes,
left delimiter=(,
right delimiter=),
row sep =-\pgflinewidth,
column sep = -\pgflinewidth,
nodes={anchor=center, minimum width=2.2em,
text height=1.8ex, text depth=0},
]{ * & * & * & \cdots & * & * \\
0 & * & * & \cdots & * &\vdots\\
\vdots & 0 & 0 & a_{ij} & \cdots & * \\
0 & \cdots & |[boxed]|a_{kj} & a_{k,j+1} & \cdots & *\\
0 & \cdots & * & * & \cdots & *\\
};
\draw[<-] ($(M-5-6)+(0.6,0)$) --++(0.4,0)node[right]{$k+1$};
\draw[<-] ($(M-1-3)+(0,0.2)$) --++(0,0.4)node[above]{$j$};
\draw[<->] ($(M-3-1)+(-0.9,0)$)node[right]{$i$} to[out=210, in=150]
($(M-4-1)+(-0.9,0)$)node[right]{$k$};
\draw[mline](M-1-2.north east) -- (M-5-2.south east);
\draw[mline](M-1-3.north east) -- (M-5-3.south east);
\draw[mline](M-2-1.south west) -- (M-2-6.south east);
\draw[mline](M-3-1.south west) -- (M-3-6.south east);
\draw[mline](M-4-1.south west) -- (M-4-6.south east);
\end{tikzpicture}

\end{document}

• op asks about twisted brackets. i admire that you understand from the question that the problem is how to write a matrix. :-). good answer (+1). Mar 13 '18 at 12:13
• @Zarko: I need to make that double curved arrow near the $I$ and $k$ just to say this rows can be interchanged. Thanks for your attention. Mar 13 '18 at 14:05
• Thanks Andrew for the time. Your solution makes mine fade. +1 Mar 13 '18 at 14:07
• @BabakS., than your problem is solved. you can accept this answer :-) Mar 13 '18 at 15:46
• The boxed entry is really awful. Mar 13 '18 at 21:37