1

I need to draw a simple matrix, with column corresponding to some sets. I tried the following:

\[D^{4}_{2}=
\left[\begin{array}{cc} 
       \diagdown & {\begin{array}{cccccc} \{1,2\} & \{1,3\} & \{2,3\} & \{1,4\} & \{2,4\} & \{3,4\} \end{array}} \\ 
      {\begin{array}{c} 
     \{1,2\} \\
     \{1,3\} \\
     \{2,3\} \\
     \{1,4\} \\
     \{2,4\} \\
     \{3,4\}
      \end{array}} & 
      {\left(\begin{array}{cccccc}
         0 & 0 & 0 & 0 & 0 & 1 \\
         0 & 0 & 0 & 0 & 1 & 0 \\
         0 & 0 & 0 & 1 & 0 & 0 \\   
         0 & 0 & 1 & 0 & 0 & 0 \\
         0 & 1 & 0 & 0 & 0 & 0 \\
         1 & 0 & 0 & 0 & 0 & 0 \\
  \end{array}\right)}
\end{array}\right] 
\]

which resulted with: matrix with titles

how can I space out the inner matrix elements, so it would fit the rows and columns of the entire table?

3

3 Answers 3

3

Here's one possible way; \overmat writes its first argument above the entries enclosed in the second argument; the separation between columns in the inner matrix was increased using 10pt for arraycolsep:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{xcolor}

\newcommand\overmat[2]{%
  \makebox[0pt][c]{$\smash{\color{white}\overbrace{\vphantom{%
    \begin{matrix}{c}#2\end{matrix}}}^{\mkern12mu \text{\color{black}#1}}}$}#2}

\newcommand\diagdown{}% temporal definition

\begin{document}

\[D^{4}_{2}=
\left[\begin{array}{c@{}c} 
       \diagdown &  \\ 
      {\begin{array}{>{\scriptstyle}c}
     \{1,2\} \\
     \{1,3\} \\
     \{2,3\} \\
     \{1,4\} \\
     \{2,4\} \\
     \{3,4\}
      \end{array}} &
    \setlength\arraycolsep{10pt} 
      {\left(\begin{array}{@{\mkern5mu}cccccc@{\mkern5mu}}
         \overmat{\{1,2\}}{0} & \overmat{\{1,3\}}{0} 
           & \overmat{\{2,3\}}{0} & \overmat{\{1,4\}}{0} 
           & \overmat{\{2,4\}}{0} & \overmat{\{3,4\}}{1} \\
         0 & 0 & 0 & 0 & 1 & 0 \\
         0 & 0 & 0 & 1 & 0 & 0 \\   
         0 & 0 & 1 & 0 & 0 & 0 \\
         0 & 1 & 0 & 0 & 0 & 0 \\
         1 & 0 & 0 & 0 & 0 & 0 \\
  \end{array}\right)}
\end{array}\right] 
\]

\end{document}

enter image description here

Since I didn't know the definition of \diagdown, I provided a partial definition \newcommand\diagdown{}. Use your actual definition in your document.

1
  • thanks! it is exactly what i needed :) BTW, diagdown is a symbol... i didn't define anything... it's just the backslash like character in the corner...
    – gilad hoch
    Apr 15, 2013 at 14:41
3

Here's a second answer using kbordermatrix - perhaps not what you want now, but a nice tool to know about. (Get kbordermatrix.sty from http://ctan.math.utah.edu/ctan/tex-archive/macros/generic/misc/kbordermatrix.sty if necessary.)

\documentclass{article}
\usepackage{amsmath}
\usepackage{kbordermatrix}
\begin{document}
\begin{equation*}
\kbordermatrix{
& \{1,2\} & \{1,3\} & \{2,3\} & \{1,4\} & \{2,4\} & \{3,4\} \\
 \{1,2\} &  0 & 0 & 0 & 0 & 0 & 1 \\
 \{1,3\} &  0 & 0 & 0 & 0 & 1 & 0 \\
 \{2,3\} &  0 & 0 & 0 & 1 & 0 & 0 \\   
 \{1,4\} &  0 & 0 & 1 & 0 & 0 & 0 \\
 \{2,4\} &  0 & 1 & 0 & 0 & 0 & 0 \\
 \{3,4\} &  1 & 0 & 0 & 0 & 0 & 0           
}
\end{equation*}
\end{document}

enter image description here

2

Here's the version using scalerel

\documentclass{article}
\usepackage{amsmath}
\usepackage{scalerel}
\begin{document}


\setlength\arraycolsep{.5ex}
\def\x{\begin{array}{c} x\\x\\x\\x\\x\\x\end{array}}

\begin{equation}
\begin{bmatrix}
\begin{array}{c}
\\ \{1,2\} \\ \{1,3\} \\ \{2,3\} \\ \{1,4\} \\ \{2,4\} \\ \{3,4\}
\end{array}
&
\begin{array}{c}
 \\ \scalerel*[1.2ex]{(}{\x}
\end{array}
&
\begin{array}{c}
\{1,2\} \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 1\\
\end{array}
&
\begin{array}{c}
\{1,3\} \\ 0 \\ 0 \\ 0 \\ 0 \\ 1 \\ 0\\
\end{array}
&
\begin{array}{c}
\{2,3\} \\ 0 \\ 0 \\ 0 \\ 1 \\ 0 \\ 0\\
\end{array}
&
\begin{array}{c}
\{1,4\} \\ 0 \\ 0 \\ 1 \\ 0 \\ 0 \\ 0\\
\end{array}
&
\begin{array}{c}
\{2,4\} \\ 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0\\
\end{array}
&
\begin{array}{c}
\{3,4\} \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0\\
\end{array}
&
\begin{array}{c}
 \\ \scalerel*[1.2ex]{)}{\x}
\end{array}
\end{bmatrix}
\end{equation}

\end{document}

enter image description here

2
  • Please, don't upload PDF file to imgur, because they are converted to a very low resolution PNG; prefer a PNG file that you can obtain in various ways (check the standalone class, for instance). I usually do a screen capture.
    – egreg
    Apr 15, 2013 at 15:42
  • @egreg I did not intend to upload PDF, but jpg. Must have inadvertantly typed or clicked the wrong file. Thanks for the heads up. Apr 15, 2013 at 16:43

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.