How can I get the explanation borders with pmatrix?

You can use the kbordermatrix package which is for some reason not CTAN but you can download it from http://www.hss.caltech.edu/~kcb/LaTeX.shtml and there is a short documentation there too. Just save the .sty file to the same folder with your actual document.

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

enter image description here


I'm sorry but I don't understand which one you are referring to. So, I've added both.

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

enter image description here

Tags:

Matrices