# How to change brackets for this modified matrix?

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


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}


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

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}