3

I'm using kbordermatrix to put some indices on my matrices. An example would be the following: basic example See the end of the post for the code behind this example.

The problem is that the spacing between the [ bracket of the kbordermatrix and the first "proper" columns seems much too large in comparison with the other matrices, and likewise for the right ].

One way I thought of to fix this is to redefine the left and right delimiters that kbordermatrix uses. It seems to work well; when using

\renewcommand{\kbldelim}{[\hspace{-1ex}}

we get the following result: first attempt That looks much better! However, now we try to do the same thing for the right bracket:

\renewcommand{\kbrdelim}{\hspace{-1ex}]}

But this gives an error:

ERROR: Missing delimiter (. inserted).

--- TeX said ---
<to be read again> 
                   \let 
l.14   }

--- HELP ---
From the .log file...

I was expecting to see something like `(' or `\{' or
`\}' here. If you typed, e.g., `{' instead of `\{', you
should probably delete the `{' by typing `1' now, so that
braces don't get unbalanced. Otherwise just proceed.
Acceptable delimiters are characters whose \delcode is
nonnegative, or you can use `\delimiter <delimiter code>'.

The obvious

\renewcommand{\kbrdelim}{\delimiter \hspace{-1ex}]}

also doesn't work.

Any ideas how to solve this?

A minimal working example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{kbordermatrix}

\begin{document}
\begin{equation*}
  \kbordermatrix{
      & 1 & 2 \\
    1 & 0 & 1 \\
    2 & 1 & 0
  }
  \times
  \begin{bmatrix}
    a & b \\
    c & d
  \end{bmatrix}
  =
  \begin{bmatrix}
    c & d \\
    a & d
  \end{bmatrix}
\end{equation*}
\end{document}

To compile it, you do have to use the kbordermatrix.sty file: CTAN.

3

Redefining \kbldelim allows you to insert content after the left delimiter, but you're too late in trying to insert content before the right delimiter \kbrdelim via a redefinition. You'll have to patch \kbordermatrix for this (using etoolbox):

enter image description here

\documentclass{article}

\usepackage{amsmath}
\usepackage{kbordermatrix,etoolbox}

\renewcommand{\kbldelim}{[\hspace*{-\arraycolsep}}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\kbordermatrix}{\right\kbrdelim}{\hspace*{-\arraycolsep}\right\kbrdelim}{}{}

\begin{document}

\[
  \kbordermatrix{
      & 1 & 2 \\
    1 & 0 & 1 \\
    2 & 1 & 0
  }
  \times
  \begin{bmatrix}
    a & b \\
    c & d
  \end{bmatrix}
  =
  \begin{bmatrix}
    c & d \\
    a & d
  \end{bmatrix}
\]

\end{document}

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.