如何使用 LaTeX、Nicematrix 和 Tikz 在矩阵下画一个花括号来描述我的列?

如何使用 LaTeX、Nicematrix 和 Tikz 在矩阵下画一个花括号来描述我的列?

我想在矩阵下画两个括号,以表明向量 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}

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

答案1

在此处输入图片描述

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

$\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] (6-1.south west) -- node [midway, below=1.5ex]{$\scriptstyle\mathcal{A}_N^i$} (6-4.south east);
                \draw[decorate,thick] (6-5.south west) -- node [midway, below=1.5ex]{$\scriptstyle\mathcal{A}_N^i$} (6-8.south east);
                \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}

答案2

6.4 版nicematrix(2021/11/23) 提供了新的命令\OverBrace\UnderBrace可用于\CodeAfter解决这种情况。括号是标准 LaTeX 的括号(即用当前数学字体构造的括号),而不是 Tikz 的括号。

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{amssymb}


\begin{document}

\section{Introduction}

\NiceMatrixOptions{parallelize-diags=false}

$\begin{pNiceMatrix}%
[first-row,
first-col,
nullify-dots,
xdots/line-style=loosely dotted,
]
         &        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      &     & \Vdots    & \Vdots       & \Ddots       & & \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
  \UnderBrace[yshift=1mm,shorten]{last-1}{last-4}{\scriptstyle\mathcal{A}_N^i}
  \UnderBrace[yshift=1mm,shorten]{last-5}{last-last}{\scriptstyle\mathcal{A}_N^i}
\end{pNiceMatrix}$

\end{document}

与往常一样nicematrix,您需要进行多次编译。

上述代码的输出

相关内容