TransWikia.com

Continuous borders through multiple blocks of a blockarray

TeX - LaTeX Asked by NoName on May 16, 2021

I have this rather complicated matrix I’m trying to make with the blkarray package.

begin{figure}
aboverulesep=0pt belowrulesep=0pt
center
    begin{blockarray}{cccccccccccc}
      & $e_1$ & $e_2$ & $dots$ & $e_j$ & $ldots$ & $e_n$ & $e'_1$ & $e'_2$ & $ldots$ & $e'_j$ & f 
      cmidrule{2-11}
    begin{block}{c[cccccc|cccc|c]}
          & & & & & & & & & & & $0$ 
          & & & $B$ & & & & & & $C$ & & $0$ 
          & & & & & & & & & & & $vdots$ 
          & & & & & & & & & & & $0$ 
      cmidrule(l){2-11}
    end{block}
    begin{block}{c[ccccccccccc]}
         $r_1$ & $1$ & & & & & & $1$ & & & & $1$ 
         $r_2$ & & $1$ & & & & & & $1$ & & & $1$ 
         $vdots$ & & & $ddots$ & & & & & & $ddots$ & & $vdots$ 
         $r_j$ & & & & $1$ & & & & & & $1$ & $1$ 
    end{block}
    end{blockarray}
end{figure}

What I want is for the matrix to be bordered with a bracket, where the columns and some of the rows have labels outside the bracket. The code I’ve pasted won’t work for that because the [s and ]s in the block declarations only apply to that block, so the brackets get broken in the middle. If I replace them with |, it looks continuous at least, but then it doesn’t quite look like a border.

How can I get continuous borders with the labels outside them? The above code renders this, but I want just a single pair of brackets.

matrix that the above code renders

3 Answers

I suggest using bigdelim which comes with multirow:

documentclass{article}

usepackage{blkarray, bigdelim, booktabs}
newcommand{mc}[1]{multicolumn{1}{c}{#1}}

begin{document}

 begin{figure}[!ht]
aboverulesep=0pt belowrulesep=0pt
centering
   $ begin{array}{c@{}c@{}*{6}{c}|*{4}{c}|c@{}c}
      & & e_1 & e_2 & dots & e_j & ldots & e_n & e'_1 & e'_2 & ldots & mc{e'_j }& mathrm{f} 
      cmidrule{3-12}
         & ldelim [{9}{*}& & & & & & & & & & & 0 & rdelim ]{9}{*}
          & & & & B & & & & & & C & & 0 
           & & & & & & & & & & & & vdots 
          & & & & & & & & & & & & 0 
      cmidrule{3-12}
         r_1 & & 1 & & & & &mc{} & 1 & & &mc{} & 1 
         r_2 & & 1 & & & & &mc{} & 1 & &mc{} & mc{} & 1
         vdots & & & & ddots & & &mc{} & & & ddots &mc{} & vdots 
         r_j & & & & & 1 & &mc{} & & & & mc{1}& 1
    end{array} $
end{figure}

end{document} 

enter image description here

Correct answer by Bernard on May 16, 2021

You can do that with the latest version of nicematrix (v. 5.11 of 2021-02-22).

documentclass{article}

usepackage{nicematrix,tikz}

begin{document}

setcounter{MaxMatrixCols}{12}

$begin{bNiceMatrix}[first-row,first-col,left-margin=7pt,xdots/shorten=4pt]
rule[-7pt]{0pt}{7pt}
       & e_1 & e_1 & Ldots & e_j & Ldots & e_n & e_1' & e_2' & Ldots & e_j' 
       & Block{4-6}{B}
             &     &        &     &        &     & Block{4-4}{C}
                                                        &     &        &      & 0 
       &     &     &        &     &        &     &      &     &        &      & 0 
       &     &     &        &     &        &     &      &     &        &      & Vdots 
       &     &     &        &     &        &     &      &     &        &      & 0 noalign{vskip1mm}
r_1    & 1   &     &        &     &        &     & 1    &     &        &      & 1 
r_2    &     & 1   &        &     &        &     &      & 1   &        &      & 1 
Vdots &     &     & Ddots &     &        &     &      &     & Ddots &      & Vdots 
r_j    &     &     &        & 1   &        &     &      &     &        & 1    & 1
CodeAfter
tikz draw (5-|1) -| (1-|11) (1-|7) -- (5-|7) ;
end{bNiceMatrix}$

end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Answered by F. Pantigny on May 16, 2021

Just another flavor. Only blkarray. I did not alter your code, so B and C are not properly centered.

a

documentclass[12pt,a4paper]{article}

usepackage{blkarray}

begin{document}
    
setlength{tabcolsep}{2.8pt}

begin{figure}

    centering

    begin{tabular}{@{hspace{3ex}}ccccccc   @{hspace{2.5ex}}cccc @{hspace{3ex}}c}
        & $e_1$ & $e_2$ & $dots$ & $e_j$ & $ldots$ & $e_n$ & $e'_1$ & $e'_2$ & $ldots$ & $e'_j$ & f 
    end{tabular}
    
    begin{blockarray}{c @{hspace{1ex}}[ ccccccc  cccc@{} ]}
        begin{block*}{ccccccc|cccc|c}
            & & & & & & & & & & & $0$ 
            & & & $B$ & & & & & & $C$ & & $0$ 
            & & & & & & & & & & & $vdots$ 
            & & & & & & & & & & & $0$ 
            cline{2-11}
        end{block*}
        begin{block*}{cccccccccccc}
            $r_1$ & $1$ & & & & & & $1$ & & & & $1$ 
            $r_2$ & & $1$ & & & & & & $1$ & & & $1$ 
            $vdots$ & & & $ddots$ & & & & & & $ddots$ & & $vdots$ 
            $r_j$ & & & & $1$ & & & & & & $1$ & $1$ 
        end{block*}
    end{blockarray}
end{figure}
    
end{document

Answered by Simon Dispa on May 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP