如何使用 Nicematrix 和 TikZ 在矩阵下绘制花括号来描述我的列?

问题描述

我想在我的矩阵下画 2 个大括号来表示向量 a 与向量 x 不同并解释原因。尽管如此,我目前的尝试只是在我的矩阵中间绘制大括号......有人有想法吗? 我尝试在这里添加一个片段,我的代码在这里https://www.overleaf.com/read/nnkpkdrwphmd

非常感谢您的帮助!

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usetikzlibrary{patterns}
\usetikzlibrary{matrix,decorations.pathreplacing}
\usetikzlibrary{decorations.pathreplacing,calligraphy}

\title{Fairness}
\author{someone}
\date{May 2021}

\begin{document}

\maketitle

\section{Introduction}

\NiceMatrixOptions{code-for-first-row = \color{red},code-for-first-col = \color{blue},code-for-last-row = \color{green},code-for-last-col = \color{magenta}}

$\begin{pNiceMatrix}%
[margin,first-row,first-col,%code-for-first-row = \mathbf{\alph{jCol}},%code-for-first-col = \mathbf{\arabic{iRow}},nullify-dots,xdots/line-style=loosely dotted,code-after = {\begin{tikzpicture}[decoration={calligraphic brace,mirror,amplitude=6pt,raise=2pt}]
                \draw[decorate,thick] (0-1.south south) -- (1-3.south east);
                node[midway,under=1.5ex]{$\scriptstyle\mathcal{A}_N^i$};
                \end{tikzpicture}}
]
&        1             & 2           & \Cdots    & k         & k+1          & k+2          & \Cdots  & m          \\
1        & a_{(1,1)}   & a_{(1,2)}   & \Cdots    & a_{(1,k)} & x_{(1,k+1)}  & x_{(1,k+2)}  & \Cdots  & x_{(1,m)}  \\
2        & a_{(2,1)}   & a_{(2,2)}   & \Cdots    & a_{(2,k)} & x_{(2,k+1)}  & x_{(2,k+2)}  & \Cdots  & x_{(2,m)}  \\
3        & a_{(3,1)}   & a_{(3,2)}   & \Cdots    & a_{(3,k)} & x_{(3,k+1)}  & x_{(3,k+2)}  & \Cdots  & x_{(3,m)}  \\
\Vdots   & \Vdots      & \Ddots      & \Cdots    & \Vdots    & \Vdots       & \Ddots       & \Cdots  & \Vdots     \\
&        &             & \Cdots      &           &           &              & \Cdots       &         &            \\
n        & a_{(n,1)}   & a_{(n,2)}   & \Cdots    & a_{(n,k)} & x_{(n,k+1)}  & x_{(n,k+2)}  & \Cdots  & x_{(n,m)}
%\CodeAfter \SubMatrix{\{}{1-1}{3-1}{.}[left-xshift=0.5em]
\end{pNiceMatrix}$

\end{document}

解决方法

  • 你不能在没有定义的情况下使用 under 之类的键,

  • south south 不是有效的锚点

  • 你只能使用非空单元格的坐标


\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usetikzlibrary{patterns}
\usetikzlibrary{matrix,decorations.pathreplacing}
\usetikzlibrary{decorations.pathreplacing,calligraphy}

\title{Fairness}
\author{someone}
\date{May 2021}

\begin{document}

\maketitle

\section{Introduction}

\NiceMatrixOptions{code-for-first-row = \color{red},code-for-first-col = \color{blue},code-for-last-row = \color{green},code-for-last-col = \color{magenta}}

$\begin{pNiceMatrix}%
[margin,name=mymatrix,first-row,first-col,%code-for-first-row = \mathbf{\alph{jCol}},%code-for-first-col = \mathbf{\arabic{iRow}},nullify-dots,xdots/line-style=loosely dotted,code-after = {\begin{tikzpicture}[decoration={calligraphic brace,mirror,amplitude=6pt,raise=2pt}]
                \draw[decorate,thick] (mymatrix-6-1.south west) -- (mymatrix-6-4.south east) node[midway,yshift=-2em]{a};
                \draw[decorate,thick] (mymatrix-6-5.south west) -- (mymatrix-6-8.south east) node[midway,yshift=-2em]{x};
                \end{tikzpicture}}
]
&        1             & 2           & \Cdots    & k         & k+1          & k+2          & \Cdots  & m          \\
1        & a_{(1,1)}   & a_{(1,2)}   & \Cdots    & a_{(1,k)} & x_{(1,k+1)}  & x_{(1,k+2)}  & \Cdots  & x_{(1,m)}  \\
2        & a_{(2,1)}   & a_{(2,2)}   & \Cdots    & a_{(2,k)} & x_{(2,k+1)}  & x_{(2,k+2)}  & \Cdots  & x_{(2,m)}  \\
3        & a_{(3,1)}   & a_{(3,2)}   & \Cdots    & a_{(3,k)} & x_{(3,k+1)}  & x_{(3,k+2)}  & \Cdots  & x_{(3,m)}  \\
\Vdots   & \Vdots      & \Ddots      & \Cdots    & \Vdots    & \Vdots       & \Ddots       & \Cdots  & \Vdots     \\
&        &             & \Cdots      &           &           &              & \Cdots       &         &            \\
n        & a_{(n,1)}   & a_{(n,2)}   & \Cdots    & a_{(n,k)} & x_{(n,k+1)}  & x_{(n,k+2)}  & \Cdots  & x_{(n,m)}
%\CodeAfter \SubMatrix{\{}{1-1}{3-1}{.}[left-xshift=0.5em]
\end{pNiceMatrix}$

\end{document}

enter image description here