# Add description next to matrix

I have the following definition of a standard basis vector: This text was compiled by the following code:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

For $\mathbb{R}^n$, we let $e_j \in \mathbb{R}^n$ (the standard basis vector)
denote the vector with a 1 in the $j$-th entry and 0 elsewhere:
$e_j = \begin{pmatrix} 0 \\ \vdots \\ 0 \\ 1 (\text{jth spot}) \\ 0 \\ \vdots \\ 0 \end{pmatrix} .$

\end{document}


But I don't like the way the entry marked as the "jth spot" comes out. I would like some way to maybe take that description out and put it next to it outside of the matrix. How could I do this?

Edit: I know that, in this case, it is possible to do this just by writing j\text{th spot} right next to the matrix, since the 1 happens to be in the center of the matrix. However, I don't like this solution because it doesn't generalize to other spots in the matrix. What other ways are there to do this?

• Shouldn‘t moving \text after \end{pmatrix} work? Or use a Kronecker notation instead. Sep 28 at 15:51
• I'd define the matrix as having entries e_{ji} with i in range [1, n] where only e_{jj} is 1. This seems like a basic thing the world of mathematics should have an agreed-upon notation for, doesn't it? Your notation I haven't seen. It definitely would make sense to leave the 1 inside and maybe point an arrow towards it with the text. But that's not really a good textbook notation, is it? Sep 28 at 16:04

You can set the element in a separate array to the right of the pmatrix. Just add the same number of lines and a closing element to avoid gobbling of the closing \\ (you'll see \mathstrut in my example). For completeness, I've added an "i-th element" label as well, so you can see what that looks like \documentclass{article}

\usepackage{amsmath,amssymb}

\begin{document}

For $\mathbb{R}^n$, we let $e_j \in \mathbb{R}^n$ (the standard basis vector) denote the vector with a~1 in the $j$-th entry and~0 elsewhere:
$e_j = \begin{pmatrix} 0 \\ \vdots \\ 0 \\ 1 \\ 0 \\ \vdots \\ 0 \end{pmatrix}~ \begin{array}{@{} c @{}} \\ \\ (i\text{-th entry}) \\ (j\text{-th entry}) \\ \\ \\ \mathstrut \end{array}$

\end{document}


Like this? With nicematrix package is simple:

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$e_j = \begin{pNiceMatrix}[last-col,nullify-dots] 0 \\ \vdots \\ 0 \\ 1 & (j\text{th spot}) \\ 0 \\ \vdots \\ 0 \end{pNiceMatrix}$

\end{document}


For showed result you need to compile this MWE at least three times since nicematrix is based on tikz package with options remember picture and overlay.

Edit:
• It should be j\text{th spot} Sep 28 at 16:44
• Thanks! One last thing: what do the options last-col and nullify-dots do? Sep 29 at 15:44
• @Mailbox, nullify-dots can be removed (since it has no function in temporary solution, it would have if instead of \vdots were used \Vdots), the last-col define "exterior" column, i.e. column after parenthesis. For more details please look in package documentation, Sep 29 at 15:56