![我如何使用 pmatrix 获取解释边界?](https://linux22.com/image/274277/%E6%88%91%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20pmatrix%20%E8%8E%B7%E5%8F%96%E8%A7%A3%E9%87%8A%E8%BE%B9%E7%95%8C%EF%BC%9F.png)
我问过这个问题聊天。如何将解释边框添加到下面的矩阵中?
\begin{align*}
C_{D_{1\succ 2}, \mathrm{increasing}} &= \underbrace{\begin{pmatrix} 1 & -1 & 1 & -1 & 1 & -1 & 1 & -1 \\ \end{pmatrix}}_{1\times 8\text{ matrix}} \\
A_{D_{1\succ 2}, \mathrm{increasing}} &=
\underbrace{\begin{pmatrix}
1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 \\
0 & 1 & 0 & 1 & 0 & 1 & 0 & 1 \\
1 & 1 & 0 & 0 & 1 & 1 & 0 & 0 \\
0 & 0 & 1 & 1 & 0 & 0 & 1 & 1 \\
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\
\end{pmatrix}}_{7\times 8 \text{ matrix}}.
\end{align*}
我想要这种 $p_1, p_2, ...$ 边框到上面的矩阵。我已经能够使用 blockarray 和 block 添加它们这里但现在我需要将它们添加到现有的 pmatrix 数据结构中。如何使用 pmatrix 来获取它?
答案1
您可以使用kbordermatrix
由于某种原因不是 CTAN 的包,但您可以从以下位置下载它http://www.hss.caltech.edu/~kcb/LaTeX.shtml那里还有一份简短的文档。只需将.sty
文件保存到与实际文档相同的文件夹中即可。
\documentclass{article}
\usepackage{mathtools,kbordematrix}
\begin{document}
% Change the default brackets to parentheses
\renewcommand{\kbldelim}{(}
\renewcommand{\kbrdelim}{)}
\[
\underbrace{\kbordermatrix{
& t_1& t_2 &\cdots & t_n & \cdots & t_h &\cdots & t_{2^n}\\
p_1 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 \\
p_2 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 1 \\
p_3 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 0 \\
p_4 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 1 \\ \hline
p_5 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
p_6 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
p_7 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\
}}_{7\times 8 \text{ matrix}}
\]
\end{document}
答案2
抱歉,我不明白您指的是哪一个。所以我添加了两个。
\documentclass{article}
\usepackage{amsmath}
\usepackage{blkarray,multirow}
\begin{document}
\begin{align*}
I_{D_{1\succ 2}, \mathrm{increasing}} &= \{53, 54, 57, 58, 69, 70, 73, 74\}_{\mathrm{DEC}} \\
C_{D_{1\succ 2}, \mathrm{increasing}} &= \underbrace{\begin{pmatrix} 1 & -1 & 1 & -1 & 1 & -1 & 1 & -1 \\ \end{pmatrix}}_{1\times 8\text{ matrix}} \\
A_{D_{1\succ 2}, \mathrm{increasing}} &=
\underbrace{\begin{blockarray}{ccccccccc}
\begin{block}{c(cccccccc)}
p_1 & 1 & 0 & 1 & 0 & 1 & 0 & 1 & 0 \\
p_2 & 0 & 1 & 0 & 1 & 0 & 1 & 0 & 1 \\
p_3 & 1 & 1 & 0 & 0 & 1 & 1 & 0 & 0 \\
p_4 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 1 \\
p_5 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
p_6 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 \\
p_7 & 0 & 0 & 0 & 0 & 1 & 1 & 1 & 1 \\
\end{block}
\end{blockarray}}_{7\times 8 \text{ matrix}}.
\end{align*}
\[
A=
\underbrace{\begin{blockarray}{ccc|cccc|c|cccc}
& t_1& t_2 & ... & ... & ... & ... & t_n & ... & t_h & ... & t_{2^n} \\
\begin{block}{c(cc|cccc|c|cccc@{\hspace*{5pt}})}
p_1 &1&0& \BAmulticolumn{4}{c|}{\multirow{4}{*}{$B_1$}}& 0 &...&1&...&1\\
p_2 &0&1& &&&&0&...&0&...&1\\
p_3 &0&0& &&&&0&...&1&...&1\\
p_4 &0&0& &&&&0&...&0&...&1\\
\cline{1-12}% don't use \hline
p_5 &0&0& \BAmulticolumn{4}{c|}{\multirow{4}{*}{$B_2$}}& 0 &...&0&...&1\\
p_6 &0&0 &&&&&0&...&0&... &1\\
... &...&... &&&&&...&...&...&... &...\\
p_{n-1} &0&0 &&&&&0&...&0&... &1\\
p_n &0&0 &&&&&1&...&0&... &1\\
\end{block}
\end{blockarray}}_{7\times 8 \text{ matrix}}.
\]
\end{document}