我正在尝试找出编写第一行和第一列中带有外部元素的矩阵的最佳方法。以下是使用array
blkarray
和kbordermatrix
包的代码。
可以看出,在使用 时,[]
中的blkarray
不会像 中那样展开。 此外 的视觉外观与 有所不同。 另一方面,使用我无法获取外部索引。\left[ \right]
array
kbordermatrix
array
array
我更愿意使用基于的东西来array
保持整个文档的视觉一致性或改变blkarray
/kbordermatrix
以便可以获得类似的结果。
\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\usepackage{blkarray}
\usepackage{kbordermatrix}
\begin{document}
\begin{equation}
P =
\begin{blockarray}{ccccc}
& BS_1 & BS_2 & \ldots & BS_B \\
\begin{block}{c[cccc]}
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{block}
\end{blockarray}
\end{equation}
\begin{equation}
P = \left[
\begin{array}{c|cccc}
& BS_1 & BS_2 & \ldots & BS_B \\ \hline
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{array} \right]
\end{equation}
\begin{equation}
P =
\kbordermatrix{%
& BS_1 & BS_2 & \ldots & BS_B \\
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B}
}
\end{equation}
\end{document}
答案1
一些可能性:
\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\usepackage{blkarray}
\begin{document}
\begin{equation}
P =
\begin{blockarray}{ccccc}
& BS_1 & BS_2 & \ldots & BS_B \\
\begin{block}{c[cccc]}
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{block}
\end{blockarray}
\end{equation}
\begin{equation}
P = \left[
\begin{array}{c|cccc}
& BS_1 & BS_2 & \ldots & BS_B \\ \hline
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{array} \right]
\end{equation}
\vspace{15pt}
\begin{equation}
P = \hspace{3.23em}\left[\hspace{-3.3em}
\begin{array}{c@{\hspace{1em}}cccc}
\noalign{\vspace{-15pt}}
& BS_1 & BS_2 & \ldots & BS_B \\
\noalign{\vspace{2pt}}
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{array} \right]
\end{equation}
\end{document}
blkarray
分隔符在本地设置时会失效\delimtershortfall
,并\delimiterfactor
使其失效。如果您不想这样,您可以本地禁用该功能:
\documentclass{article}
\usepackage{mathtools}
\usepackage{array}
\usepackage{blkarray}
\newdimen\zzzzdimen
\newcount\zzzzcount
\begin{document}
\begin{equation}
\let\delimitershortfall\zzzzdimen
\let\delimiterfactor\zzzzcount
P =
\begin{blockarray}{ccccc}
& BS_1 & BS_2 & \ldots & BS_B \\
\begin{block}{c[cccc]}
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{block}
\end{blockarray}
\end{equation}
\begin{equation}
P = \left[
\begin{array}{c|cccc}
& BS_1 & BS_2 & \ldots & BS_B \\ \hline
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{array} \right]
\end{equation}
\vspace{15pt}
\begin{equation}
P = \hspace{3.23em}\left[\hspace{-3.3em}
\begin{array}{c@{\hspace{1em}}cccc}
\noalign{\vspace{-15pt}}
& BS_1 & BS_2 & \ldots & BS_B \\
\noalign{\vspace{2pt}}
UE_1 & P_{1,1} & P_{1,2} & \ldots & P_{1,B} \\
UE_2 & P_{2,1} & P_{2,2} & \ldots & P_{1,B} \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
UE_U & P_{U,1} & P_{U,2} & \ldots & P_{U,B} \\
\end{array} \right]
\end{equation}
\end{document}