[Tex/LaTex] How to define the proper space between elements of a matrix

matricesspacing

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:

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

Best Answer

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}


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