[Tex/LaTex] Centering \vdots in a sparse matrix with an even number of rows

horizontal alignmentmatrices

I am trying to define only the non-zeros elements in a sparse matrix, thus using some \vdots where the entries are zeros and specifying the row when needed (using the blockarray command, with \usepackage{blkarray} in the preamble). My matrix only has 2 columns (or 4), so I can't center the \vdots like I would like (the problem would be solved if the matrix had an odd number of columns). Here's an exemple:

$\begin{blockarray}{ccc}
  \begin{block}{[cc]l}
   \vdots \\
   a & b & /K-1  \\
   c & d & /K \\
  \vdots \\
 \end{block}
\end{blockarray}$

As you can see in this example, while I specified to center the entries inbetween [ and ], the \vdots are centered on the first column. If I replace cc by any combination of r, c, and l it is still not satisfying. Also if I put the \vdots between any number of & on the right and/or on the left it still doesn't work.

The other solution I have (but not satisfactory either) is to add another column:

$\begin{blockarray}{cccc}
  \begin{block}{[ccc]l}
   &\vdots& \\
   a & & b & /K-1  \\
   c & & d & /K \\
  &\vdots& \\
 \end{block}
\end{blockarray}$

But as you can see now the non-zeros entries are too far apart and the result is not really pretty.

Thank you for your time and your help.

Best Answer

blkarray is able to do it without extra packages, just use \BAmulticolumn, which is the specific command for a blockarray:

\documentclass{article}
\usepackage{blkarray}

\begin{document}

\[
\begin{blockarray}{ccc}
  \begin{block}{[cc]l}
   \BAmulticolumn{2}{c}{\vdots} & \\
   a & b & /K-1  \\
   c & d & /K \\
   \BAmulticolumn{2}{c}{\vdots} & \\
 \end{block}
\end{blockarray}
\]

\end{document}

enter image description here