1

The following code displays a matrix that has the value of 1 in the cell (i,j) and the value 0 in all the other cells. The code shows the rightarrow with the label "row i" and I want to add an uparrow at the bottom of the table in the position of the column j with the label "column j" below it. How can I do this?

\documentclass[a4paper,twoside,10pt]{book}
\usepackage {tikz}
\usetikzlibrary {positioning,graphs,calc,decorations.pathmorphing,shapes,arrows.meta,arrows,shapes.misc}
\usepackage{tikz-cd}
\usepackage{greektex}
\usepackage[american,greek,greek.polytoniko]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
e_{ij}=\begin{pmatrix}
0&0&0&\dots&0&\dots&0&0\\0&0&0&\dots&0&\dots&0&0\\\vdots&\vdots&\vdots&\vdots&\vdots&\ddots&\vdots&\vdots\\
0&0&0&\dots&1&\dots&0&0\\\vdots&\vdots&\vdots&\vdots&\vdots&\ddots&\vdots&\vdots\\
0&0&0&\dots&0&\dots&0&0\\0&0&0&\dots&0&\dots&0&0\\
\end{pmatrix}\xleftarrow{\hspace*{1.1cm}}\mbox{\small{\textlatin{row} }}i\\
\end{equation*}
\end{document} 
1
  • 2
    You should take a look at the nicematrix package.
    – Bernard
    Sep 19, 2019 at 9:03

2 Answers 2

4

With nicematrix, as mentioned @Bernard in his comment:

\documentclass[a4paper,twoside,10pt]{book}
\usepackage{mathtools}
\usepackage{nicematrix}

\begin{document}

\[
\begin{pNiceArray}{*{8}{C}}[last-col,
    code-after={\tikz\draw[<-] ([yshift=-3pt]6-5.south) -- ++ (0,-0.6) node[below] {column $j$};}]
0      & 0      & 0      & \dots  & 0      & \dots  & 0      & 0      &     \\
\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots &     \\
0      & 0      & 0      & \dots  & 1      & \dots  & 0      & 0      & \longleftarrow\text{ row } i\\
\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots &     \\
0      & 0      & 0      & \dots  & 0      & \dots  & 0      & 0      &     \\
0      & 0      & 0      & \dots  & 0      & \dots  & 0      & 0      &     \\
\end{pNiceArray}
\]

\end{document}

enter image description here

For above result two compilations are needed.

4

If you want, you can use nicematrix with no Tikz explicit instruction (even if nicematrix uses internally Tikz for several functionnalities).

\documentclass[a4paper,twoside,10pt]{book}
\usepackage{mathtools}
\usepackage{nicematrix}

\begin{document}
\[
\begin{pNiceArray}{*{8}{C}}[last-col,last-row]
0      & 0      & 0      & \dots  & 0      & \dots  & 0      & 0      &     \\
\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots &     \\
0      & 0      & 0      & \dots  & 1      & \dots  & 0      & 0      & \longleftarrow\text{ row } i\\
\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots &     \\
0      & 0      & 0      & \dots  & 0      & \dots  & 0      & 0      &     \\
0      & 0      & 0      & \dots  & 0      & \dots  & 0      & 0      &     \\
       &        &        &    & 
\begin{array}{@{}c@{}}
\uparrow \\
\mathclap{\text{column } j} 
\end{array}
\end{pNiceArray}
\]
\end{document}

Result of the previous code

1
  • 1
    Upvote for gave solution without using additional package like tikz...
    – MadyYuvi
    Sep 19, 2019 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .