Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have asked this question in chat. How can I add the explanation borders to the below matrix?

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

I want this kind of $p_1, p_2, ...$ borders to the matrix above. I have been able to add them with blockarray and block here but now I need to add them to the existing pmatrix data-structure. How can I get it with the pmatrix?

enter image description here

share|improve this question
1  
Consider the kbordermatrix package: hss.caltech.edu/~kcb/TeX/kbordermatrix.pdf (you may need to get the .sty file yourself: mirrors.ustc.edu.cn/CTAN/macros/generic)/misc/kbordermatrix.sty. –  Ethan Bolker Aug 26 '13 at 14:11

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer
    
Do you know whether there is any easy way to get the underbrace only under the matrix not under the explanation column $p_1,p_2,...,p_7$? –  hhh Aug 26 '13 at 15:56
    
@hhh You can use \cline{2-12} starting from the second column –  percusse Aug 27 '13 at 14:38

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

share|improve this answer
    
It is slightly misleading to have the underbrace under the explanation borders because the matrix is just the thing inside the brackets. How to get it only under the brackets (not having the $p_1,p_2, ...,p_n$ column)? –  hhh Aug 26 '13 at 15:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.