我不知道如何添加标签“ABCDE”和“12345678910”。我想将其设置为矩阵而不是表格。我该如何实现?
\documentclass{article}
\begin{document}
\begin{table}[]
\begin{tabular}{cccccc}
& 5 & 4 & 4 & - & \textbf{5} \\
& - & 3 & 5 &\textbf{ 3} & 4 \\
& 5 & 2 & - & \textbf{2} & 3 \\
& - & \textbf{2} & 3 & 1 & 2 \\
& 4 & - & \textbf{5} & 4 & 5 \\
& \textbf{5}&3 & - & 3 & 5 \\
&3 & \textbf{2} & 3 & 2 & - \\
&5 & \textbf{3} & 4 & - & 5 \\
& \textbf{4} & 2 & 5 & 4 &- \\
&\textbf{5} & - & 5 & 3 & 4 \\
& & & & &
\end{tabular}
\end{table}
\end{document}
答案1
不需要像tikz
那样的大锤:blkarray
很容易就完成了:
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{blkarray}
\usepackage[svgnames]{xcolor}
\begin{document}
\[ \mathbf{R }= \begin{blockarray}{r*{5}{ >{\color{LightSalmon}}c}}
& A & B & C & D & E \\
\begin{block}{ >{\scriptstyle}r!{\,}(ccccc)}
1 & 5 & 4 & 4 & - & \mathbf{5} \\
2 & - & 3 & 5 &\mathbf{ 3} & 4 \\
3 & 5 & 2 & - & \mathbf{2} & 3 \\
4 & - & \mathbf{2} & 3 & 1 & 2 \\
5 & 4 & - & \mathbf{5} & 4 & 5 \\
6 & \mathbf{5}&3 & - & 3 & 5 \\
7 & 3 & \mathbf{2} & 3 & 2 & - \\
8 & 5 & \mathbf{3} & 4 & - & 5 \\
9 & \mathbf{4} & 2 & 5 & 4 &- \\
10 & \mathbf{5} & - & 5 & 3 & 4 \\
\end{block}
\end{blockarray} \]%
\end{document}
答案2
与。{pNiceMatrix}
nicematrix
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\begin{table}[tbp]
$\mathbf{R} =
\begin{pNiceMatrix}%
[first-col,
first-row,
code-for-first-col = \color{blue},
code-for-first-row = \color{blue}]
& A & B & C & D & E \\
1 & 5 & 4 & 4 & - & \mathbf{5} \\
2 & - & 3 & 5 &\mathbf{ 3} & 4 \\
3 & 5 & 2 & - & \mathbf{2} & 3 \\
4 & - & \mathbf{2} & 3 & 1 & 2 \\
5 & 4 & - & \mathbf{5} & 4 & 5 \\
6 & \mathbf{5}&3 & - & 3 & 5 \\
7 & 3 & \mathbf{2} & 3 & 2 & - \\
8 & 5 & \mathbf{3} & 4 & - & 5 \\
9 & \mathbf{4} & 2 & 5 & 4 &- \\
10 & \mathbf{5} & - & 5 & 3 & 4
\end{pNiceMatrix}$
\end{table}
\end{document}