1

I found this code here (stackexchange) and modified it for the matrix I needed to make. But I want to have thoses brackets[ ]. I tried to change blockarray for \left[ and \right]. Can anybody help me please? I needed \usepackage{blkarray} for this.

 \[ \newcounter{rowct}\newcounter{colct}%\setlength\extrarowheight{1cm}
    \begin{blockarray}{*{8}{c}}
    \begin{block}{r*{7}{>{\refstepcounter{colct}\mathclap{\mathbf\thecolct}}c}}
     & & & & & & & \\%[-1ex]
     \end{block}
     \begin{block}{ >{\refstepcounter{rowct}\mathbf\therowct}r( >{\hspace{0.2em}}*{7}{c} <{\hspace{0.2em}})}
      & 0 & 1 & 1 & 1 & 1 & 0 & 0 \rule{0pt}{3.5ex} \\
      & 1 & 0 & 1 & 1 & 0 & 1 & 0 \\
      & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\
      & 1 & 1 & 0 & 0 & 1 & 1 & 1 \\
      & 1 & 0 & 0 & 1 & 0 & 0 & 1\\
      & 0 & 1 & 0 & 1 & 0 & 0 & 0 \\
      & 0 & 0 & 0 & 1 & 1 & 0 & 0\\[1ex]
     \end{block}
    \end{blockarray}
    \]

enter image description here

0

Just replace the pair ( ) in the second block with a pair of [ ]:

\documentclass{article}
\usepackage{mathtools}
\usepackage{blkarray}

\begin{document}

\[ \newcounter{rowct}\newcounter{colct}%\setlength\extrarowheight{1cm}
\begin{blockarray}{*{8}{c}}
\begin{block}{r*{7}{>{\refstepcounter{colct}\mathclap{\mathbf\thecolct}}c}}
 & & & & & & & \\%[-1ex]
 \end{block}
 \begin{block}{ >{\refstepcounter{rowct}\mathbf\therowct}r[ >{\hspace{0.2em}}*{7}{c} <{\hspace{0.2em}}]}
  & 0 & 1 & 1 & 1 & 1 & 0 & 0 \rule{0pt}{3.5ex} \\
  & 1 & 0 & 1 & 1 & 0 & 1 & 0 \\
  & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\
  & 1 & 1 & 0 & 0 & 1 & 1 & 1 \\
  & 1 & 0 & 0 & 1 & 0 & 0 & 1\\
  & 0 & 1 & 0 & 1 & 0 & 0 & 0 \\
  & 0 & 0 & 0 & 1 & 1 & 0 & 0\\[1ex]
 \end{block}
\end{blockarray}
\]

\end{document} 

enter image description here

1
  • Got it! This answers my question. Thank you! – Aezir Oct 8 '20 at 23:15
0

You can do that easily with nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\begin{bNiceMatrix}%
  [ 
   first-row,
   code-for-first-row = \mathbf{\arabic{jCol}},
   first-col,
   code-for-first-col = \mathbf{\arabic{iRow}},
  ]
&   &   &   &   &   &   &   \\
& 0 & 1 & 1 & 1 & 1 & 0 & 0 \\
& 1 & 0 & 1 & 1 & 0 & 1 & 0 \\
& 1 & 1 & 0 & 0 & 0 & 0 & 0 \\
& 1 & 1 & 0 & 0 & 1 & 1 & 1 \\
& 1 & 0 & 0 & 1 & 0 & 0 & 1 \\
& 0 & 1 & 0 & 1 & 0 & 0 & 0 \\
& 0 & 0 & 0 & 1 & 1 & 0 & 0 \\
\end{bNiceMatrix}$

\end{document}

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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