1

I have a matrix with labels on the left and top. Now I want to have a label on all sides of the matrix. How can I change my code?

\documentclass[10 pt, a4paper, leqno, oneside] {report}
\usepackage{kbordermatrix}
\begin{document}

\renewcommand{\kbldelim}{(}% Left delimiter
\renewcommand{\kbrdelim}{)}% Right delimiter
\[
  \tilde{\textbf{m}} = \kbordermatrix{
    \mbox{} & c_1 & c_2 & c_3 & c_4 & c_5 \\
    % & c_1 & c_2 & c_3 & c_4 & c_5 \\
    r_1 & 1 & 1 & 1 & 1 & 1 \\
    r_2 & 0 & 1 & 0 & 0 & 1 \\
    r_3 & 0 & 0 & 1 & 0 & 1 \\
    r_4 & 0 & 0 & 0 & 1 & 1 \\
    r_5 & 0 & 0 & 0 & 0 & 1 
  }
\]

\end{document}
1

You can use blkarray to construct the components of a multi-indexed array:

enter image description here

\documentclass{article}

\usepackage{kbordermatrix,blkarray}

\begin{document}

\renewcommand{\kbldelim}{(}% Left delimiter
\renewcommand{\kbrdelim}{)}% Right delimiter
\[
  \tilde{\textbf{m}} = \kbordermatrix{
    \mbox{} & c_1 & c_2 & c_3 & c_4 & c_5 \\
    r_1 & 1 & 1 & 1 & 1 & 1 \\
    r_2 & 0 & 1 & 0 & 0 & 1 \\
    r_3 & 0 & 0 & 1 & 0 & 1 \\
    r_4 & 0 & 0 & 0 & 1 & 1 \\
    r_5 & 0 & 0 & 0 & 0 & 1 
  }
\]

\newcommand{\idxsize}{\scriptstyle}
\[
  \tilde{\textbf{m}} =
  \begin{blockarray}{>{\scriptstyle}c
      >{\hspace{\arraycolsep}\idxsize}c*{4}{>{\idxsize}c}<{\hspace{\arraycolsep}}>{\idxsize}c}
    & c_1 & c_2 & c_3 & c_4 & c_5 & \\
    \begin{block}{>{\idxsize}c(>{\hspace{\arraycolsep}}ccccc<{\hspace{\arraycolsep}})>{\idxsize}c}
      r_1 & 1 & 1 & 1 & 1 & 1 & r_5 \\
      r_2 & 0 & 1 & 0 & 0 & 1 & r_4 \\
      r_3 & 0 & 0 & 1 & 0 & 1 & r_3 \\
      r_4 & 0 & 0 & 0 & 1 & 1 & r_2 \\
      r_5 & 0 & 0 & 0 & 0 & 1 & r_1 \\
    \end{block}
    \\[-1.2\normalbaselineskip] & c_5 & c_4 & c_3 & c_2 & c_1 &
  \end{blockarray}
\]

\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.