7

I have the following definition of a standard basis vector:

Definition of 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?

2
  • Shouldn‘t moving \text after \end{pmatrix} work? Or use a Kronecker notation instead.
    – MS-SPO
    Sep 28, 2023 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, 2023 at 16:04

2 Answers 2

5

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

enter image description here

\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}
8

Like this?

enter image description here

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:
Considered are @egreg comments.

5
  • Why does the code need to be compiled three times?
    – Mailbox
    Sep 28, 2023 at 16:38
  • 4
    @Mailbox It uses TikZ in the background and positioning extra items requires multiple measuring steps.
    – egreg
    Sep 28, 2023 at 16:43
  • It should be j\text{th spot}
    – egreg
    Sep 28, 2023 at 16:44
  • Thanks! One last thing: what do the options last-col and nullify-dots do?
    – Mailbox
    Sep 29, 2023 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,
    – Zarko
    Sep 29, 2023 at 15:56

You must log in to answer this question.

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