Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Welcome to TeX.sx! –  Peter Jansson Apr 15 '13 at 14:11
    
@StevenB.Segletes i don't have the package scalerel, and i'm googling right now on how to add a package, but since i need to distribute the lines evenly, and not like the example you linked to, isn't there a better way to do so? –  gilad hoch Apr 15 '13 at 14:39
    
add comment

3 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '13 at 14:41
add comment

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

share|improve this answer
add comment

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

share|improve this answer
    
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 '13 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. –  Steven B. Segletes Apr 15 '13 at 16:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.