1

I have a matrix with "description" of the Elements on the left side and on the matrix. So the matrix is in exactly the same row as the description, but the columns are not in exactly the same line as the description. How can I improve this?

  $\begin{array}{r|c}
  & \begin{matrix} A & B & C & D & E\end{matrix} \\
  \hline
  \begin{matrix}
  A\\
  B\\
  C\\
  D\\
  E
 \end{matrix} &
 \begin{pmatrix}
  0 & 1 & 0 & 0 & 1\\
  1 & 0 & 1 & 1 & 1\\
  0 & 1 & 0 & 0 & 1\\
  0 & 1 & 0 & 0 & 1\\
  0 & 1 & 0 & 0 & 1\\
 \end{pmatrix}
 \end{array}$
  • Welcome to TeX,SE! Perhaps you want to have a look at blkarray. – user121799 Oct 10 '18 at 21:08
1

A solution based on blkarray:

\documentclass{article}
\usepackage{mathtools}
\usepackage{blkarray, bigstrut}

\begin{document}

 \[ \setlength{\bigstrutjot}{4pt}
 \begin{blockarray}{r@{\enspace\vrule}rccccc}
   \phantom{A}& & A & B & C & D & E \\
  \BAhline
  \begin{block}{r@{\enspace\vrule}r(ccccc)}
 A & & 0 & 1 & 0 & 0 & 1 \bigstrut[t]\\
 B & & 1 & 0 & 1 & 1 & 1 \\
 C & & 0 & 1 & 0 & 0 & 1 \\
 D & & 0 & 1 & 0 & 0 & 1 \\
 E & & 0 & 1 & 0 & 0 & 1 \bigstrut[b]\\
 \end{block}
 \end{blockarray} \]

\end{document} 

enter image description here

0

A solution with tabular and a "game" with its column widths

\documentclass[12pt,a4paper]{article}       

\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\begin{document}

\begin{tabular}{c|@{}p{0.007cm}>{\raggedright\arraybackslash}m{0.6cm}@{\raggedleft\arraybackslash}m{0.1cm}>{\raggedleft\arraybackslash}m{0.15cm}>{\raggedleft\arraybackslash}m{0.15cm}>{\raggedleft\arraybackslash}m{0.1cm}}
 & &  A & B & C & D & E\\
  \hline
  A&\multicolumn{6}{@{}l}{\multirow{5}{*}{
  $\begin{pmatrix}
  0 & 1 & 0 & 0 & 1\\
  1 & 0 & 1 & 1 & 1\\
  0 & 1 & 0 & 0 & 1\\
  0 & 1 & 0 & 0 & 1\\
  0 & 1 & 0 & 0 & 1\\
 \end{pmatrix}$
 }}\\
  B&&&&&&\\
  C&&&&&&\\
  D&&&&&&\\
  E&&&&&&
\end{tabular}

\end{document}

enter image description here

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.