2

I'm trying to write a matrix which has the indexes on top of the actual matrix, ie. something like:

enter image description here

This is similar to this question here, but I haven't managed to avoid the indexes on the sides of the matrix - I just want them up top.

2 Answers 2

4

You can do that with nicematrix:

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\setcounter{MaxMatrixCols}{15}

$\begin{bNiceMatrix}[first-row]
x & x^2 & x^3 & x^4 & x^5 & x^6 & x^7 & x^8 & x^9 & x^{10} \\
r & -r  & 0     & 0    & 0     & 0     & 0      & 0      & 0    & 0    & \ldots \\
0 & r^2 & -2r^2 &      & 0     & 0     & 0      & 0      & 0    & 0    & \ldots \\
0 & r^3 & -3r^3 & 3r^3 & r^3   & 0     & 0      & 0      & 0    & 0    & \ldots \\
0 & 0   & 0     & r^4  & -4r^4 & 6r^4  & -4r^4  & r4     & 0    & 0    & \ldots \\
0 & 0   & 0     & 0    & r^5   & -5r^5 &  10r^5 & -10r^5 & 5r^5 & -r^5 & \ldots \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots 
\end{bNiceMatrix}$

\end{document}

Ouput of the above code

3
  • merci pour votre réponse :). Could you please clarify what "\setcounter{MaxMatrixCols}{15}" does? Also, I can't manage to get your code to compile, I get the error: "! Package nicematrix Error: The option "first-row" is unknown for the (nicematrix) environment {NiceMatrix} and its variants." Commented Sep 21, 2020 at 15:29
  • You can't put more than MaxMatrixCols columns in an matrix of amsmath (and nicematrix). The initial value of that parameter is 10. I have changed it since your matrix has more than 10 columns. Commented Sep 21, 2020 at 15:35
  • The error message you have obtained shows that the version of the nicematrix package installed on your computer is not up-to-date. You should update thoroughly your TeX installation. Commented Sep 21, 2020 at 15:37
3

Just omit the final entries on each row in the blockarray that otherwise serve to label the rows (but do not omit the & preceding them.

To do a slightly simpler example than yours (since you didn't provide any source code, I didn't want to laboriously type all the entries of your 11-column matrix:

\documentclass[11pt, a4paper]{article}
\usepackage{amsmath,blkarray, bigstrut}

\begin{document}

 \[
     \begin{blockarray}{*{5}{>{\scriptstyle}c}}
       x & x^{2}& x^{3} &  \\
        \begin{block}{[cccc] >{\scriptstyle}c}
         \bigstrut[t]  r & -r & 0 & \cdots & \\         
          0 & r^{2} & -2 r^{2} & \cdots & \\
          0 & 0 & r^{3} & \cdots & \\
          0 & 0 & 0 & \cdots & \\
          \vdots & \vdots & \vdots &\ddots\\
        \end{block}
      \end{blockarray}
 \]

 \end{document} 

Block array

You must log in to answer this question.

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