具有頂部索引的矩陣

具有頂部索引的矩陣

我正在嘗試編寫一個矩陣,該矩陣的索引位於實際矩陣之上,即。就像是:

在此輸入影像描述

這類似於這個問題在這裡,但我還沒有設法避免矩陣兩側的索引 - 我只是希望它們位於頂部。

答案1

你可以這樣做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}

上述程式碼的輸出

答案2

只需省略每行的最終條目,否則blockarray用於標記行(但不要這樣做)不是省略&前面的內容。

做一個比你的稍微簡單的例子(因為你沒有提供任何原始碼,我不想費力地輸入 11 列矩陣的所有條目:

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

區塊陣列

相關內容