# Space between columns in blockarray

I'm looking for a way to change the column space in a blockarray. I tried by setting \arraycolsep and \setlength{\tabcolsep}{20pt} but none of these solutions were successful. Here is the code :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{blkarray}

\begin{document}
$\arraycolsep=53.4pt \small \begin{blockarray}{*{3}{c}} & a & b \\ \begin{block}{c[*{2}{c}]} a & 0 & 1 \\ b & 2 & 3 \\ \end{block} \end{blockarray}$
\end{document}


Result is :

I'd like to add more space between the columns a and b of the matrix. Any idea how to achieve this? Ideally, the solution I'm looking for is still using blkarray but it's not a requirement.

No idea why, but it uses \BA@colsep so you need to access the command with @ in its name.

\documentclass{article}

\usepackage{blkarray}

\begin{document}

$\makeatletter\setlength\BA@colsep{53.4pt}\makeatother \begin{blockarray}{c c c} & a & b \\ \begin{block}{c[c @{\hspace{50pt}} c]} a & 0 & 1 \\ b & 2 & 3 \\ \end{block} \end{blockarray}$

\end{document}


• ...nope... that's not it. – Werner May 8 at 22:15
• @Werner aaaaaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhh – David Carlisle May 8 at 22:20
• @Werner sorry about that, fixed, as you may have guessed I borrowed your MWE as the OP did not supply one:-) – David Carlisle May 8 at 22:25
• if you use @{} after the first labels column it will not insert the space there, just as in a normal tabular. – David Carlisle May 8 at 22:26
• @DavidCarlisle Sorry, I edited my question so that the given example is a MWE – Spazz May 8 at 22:46

With nicematrix you get the desired spacing by setting \arraycolsep. And a friendlier syntax, by the way.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}

\begin{document}

$\setlength{\arraycolsep}{20pt} \begin{bNiceMatrix}[first-row,first-col] & a & b \\ a & 0 & 1 \\ b & 2 & 3 \end{bNiceMatrix}$

\end{document}


Here is an option:

\documentclass{article}

\usepackage{blkarray}

\begin{document}

$\begin{blockarray}{c c @{\hspace{50pt}} c} & a & b \\ \begin{block}{c[c @{\hspace{50pt}} c]} a & 0 & 1 \\ b & 2 & 3 \\ \end{block} \end{blockarray}$

\end{document}

• Is there a way to use this solution while still declaring columns with the syntax *{3}{c} ? I tried *{3}{c}@{\hspace{50pt}} but the result is quite strange. Also tried *{3}{>{\hspace{50pt}}c} but then columns labels aren't aligned with columns content. – Spazz May 8 at 22:54
• @Spazz: Yes. You can use c *{2}{c@{\hspace{50pt}}} for the outer blockarray and c [*{2}{c@{\hspace{50pt}}}] for the inner block. However, for 2 columns its a bit superfluous to use the * notation. For larger blocks it might be useful. It would seem a bit weird to have the outer indices pushed out as well, but if need be, you can use *{3}{c@{\hspace{50pt}}} for the outer blockarray. – Werner May 8 at 23:02

The separating length is \BA@colsep, and by default, it is equal to tabcolsep. I defined a new command to change it:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{blkarray}

\makeatletter
\newcommand{\setBAcolsep}[1]{\BA@colsep=#1}
\makeatother

\begin{document}

$\small\setBAcolsep{53.4pt} \begin{blockarray}{*{3}{c}} & a & b \\ \begin{block}{c[*{2}{c}]} a & 0 & 1 \\ b & 2 & 3 \\ \end{block} \end{blockarray}$

\end{document}