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

标签 matrix latex curly-braces 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 这样的键

  • 南南不是有效的 anchor

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


\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

关于matrix - 如何使用 Nicematrix 和 TikZ 在矩阵下绘制大括号来描述我的列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67840626/

相关文章:

loops - 在 Smalltalk 中迭代矩阵元素并在返回 true 时停止

r - 在 R 中,如何在使用双花括号时选择列?为什么不能将 $ 运算符与大括号一起使用?

c - 在 C 中使用指针交换列

r - 在 r 中转换矩阵的更快方法?

latex - 它不显示图形,而只显示一个框架和文件名内,尽管图像文件上传到背面的同一文件夹中

csv - 使用 MikTex 在 Latex 文档中包含带有 csvsimple 的四列以上的 CSV 文件

latex - LaTeX 表格中的自动换行符

regex - 带有 {} grep 和正则表达式的大括号 : Why does it exceed the maximum value?

visual-studio-2008 - 转到 Visual Studio 中的匹配大括号吗?

c - c 中的矩阵和对角线任务