如何为该矩阵添加标签标题?

如何为该矩阵添加标签标题?

我怎样才能为该矩阵添加这样的标题?

在此处输入图片描述

我试过但由于开头是 A1/A2,因此无法使其适用于这种情况。

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{blkarray}
\usepackage{nicematrix}

\newcommand{\clr}[2]{\textcolor{red}{#1}/\textcolor{blue}{#2}} 

\begin{document}

\[
\clr {A_1}{A_2}=\begin{blockarray}{cccccccc}
 & V_1& V_2 & V_3 & V_4 & V_5 & V_6 & V_7   \\
\begin{block}{c(ccccccc)}
V_1 &  \clr{0}{0} &\clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
V_2 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}  \\
V_3 & \clr{1}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
V_4 & \clr{0}{0} & \clr{0}{1} &\clr{0}{0} & \clr{0}{1} & \clr{1}{0} & \clr{1}{0} & \clr{0}{0} \\
V_5 & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0}   \\
V_6 & \clr{0}{0} & \clr{0}{1} & \clr{0}{1} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}   \\
V_7 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0}   \\
\end{block}
\end{blockarray}
\]

\end{document}

这是带有 nicematrix 的矩阵。我添加它只是为了防止添加标题比添加 blockarray 更容易。

\[
\clr {A_1}{A_2}=\begin{pNiceMatrix}[first-row,first-col]
 & V_1& V_2 & V_3 & V_4 & V_5 & V_6 & V_7   \\
V_1 &  \clr{0}{0} &\clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
V_2 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}  \\
V_3 & \clr{1}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
V_4 & \clr{0}{0} & \clr{0}{1} &\clr{0}{0} & \clr{0}{1} & \clr{1}{0} & \clr{1}{0} & \clr{0}{0} \\
V_5 & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0}   \\
V_6 & \clr{0}{0} & \clr{0}{1} & \clr{0}{1} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}   \\
V_7 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0}   \\
\end{pNiceMatrix}
\]

答案1

这是一个使用的解决方案nicematrix

C

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{blkarray}
\usepackage{nicematrix}

\usepackage{tikz}% added 
\usetikzlibrary{decorations.pathreplacing, calligraphy}% added

\newcommand{\clr}[2]{\textcolor{red}{#1}/\textcolor{blue}{#2}} 

\begin{document}
    
\[
\clr {A_1}{A_2}=\begin{pNiceMatrix}[first-row,first-col, margin] % added margin
    & V_1& V_2 & V_3 & V_4 & V_5 & V_6 & V_7   \\
    V_1 &  \clr{0}{0} &\clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
    V_2 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}  \\
    V_3 & \clr{1}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
    V_4 & \clr{0}{0} & \clr{0}{1} &\clr{0}{0}  & \clr{0}{1} & \clr{1}{0} & \clr{1}{0} & \clr{0}{0} \\
    V_5 & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0}   \\
    V_6 & \clr{0}{0} & \clr{0}{1} & \clr{0}{1} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}   \\
    V_7 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0}   \\
    \CodeAfter
    \tikz
    \draw [decorate,decoration = {calligraphic brace,mirror,amplitude=10pt},thick]
    ([yshift=-5pt]last-1.south west) -- ([yshift=-5pt]last-7.south east)   node [black,midway,yshift=-18pt] {Some caption here};
\end{pNiceMatrix}
\]

\end{document}

添加

添加xshift两端可以支撑整个矩阵。

d

\[
\clr {A_1}{A_2}=\begin{pNiceMatrix}[first-row,first-col, margin] % added margin
    & V_1& V_2 & V_3 & V_4 & V_5 & V_6 & V_7   \\
    V_1 &  \clr{0}{0} &\clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
    V_2 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}  \\
    V_3 & \clr{1}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
    V_4 & \clr{0}{0} & \clr{0}{1} &\clr{0}{0}  & \clr{0}{1} & \clr{1}{0} & \clr{1}{0} & \clr{0}{0} \\
    V_5 & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0}   \\
    V_6 & \clr{0}{0} & \clr{0}{1} & \clr{0}{1} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}   \\
    V_7 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0}   \\
    \CodeAfter
    \tikz
    \draw [decorate,decoration = {calligraphic brace,mirror,amplitude=10pt},thick]
    ([yshift=-5pt,xshift=-25pt]last-1.south west) -- ([yshift=-5pt ,xshift=10pt]last-7.south east)   node [black,midway,yshift=-18pt] {Some caption here};
\end{pNiceMatrix}
\]

答案2

与您想要的不一样,但非常接近!如果我找到相同的解决方案,我会编辑我的答案

在此处输入图片描述

\documentclass[journal]{IEEEtran}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{blkarray}
\usepackage{nicematrix}

\newcommand{\clr}[2]{\textcolor{red}{#1}/\textcolor{blue}{#2}} 
\newcommand\undermat[2]{% http://tex.stackexchange.com/a/102468/5764
  \makebox[0pt][l]{$\smash{\underbrace{\phantom{%
    \begin{matrix}#2\end{matrix}}}_{\text{$#1$}}}$}#2}

\begin{document}
 \begin{equation*}
\clr {A_1}{A_2}=
\begin{array}{c}
%\underbrace{%
\begin{matrix}
\bordermatrix{& V_1& V_2 & V_3 & V_4 & V_5 & V_6 & V_7 \\
V_1 &  \clr{0}{0} &\clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
V_2 & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}  \\
V_3 & \clr{1}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} \\
V_4 & \clr{0}{0} & \clr{0}{1} &\clr{0}{0} & \clr{0}{1} & \clr{1}{0} & \clr{1}{0} & \clr{0}{0} \\
V_5 & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{0}{1} & \clr{0}{0} & \clr{0}{0} & \clr{1}{0}   \\
V_6 & \clr{0}{0} & \clr{0}{1} & \clr{0}{1} & \clr{0}{0} & \clr{1}{0} & \clr{0}{0} & \clr{0}{0}   \\
V_7 & \undermat{qqqqqqqqqqqqqqqqqqqq}{\clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0} & \clr{0}{0}}}
\end{matrix}\\
%\textrm{This is $A$}\\
\end{array}
\end{equation*}
 
\end{document}

相关内容