# Table with left and underbrackets centering

I have written this code in order to obtain a simple I x J matrix.

\begin{table}[H]
\caption{Invidual/Attributes Matrix}
\begin{center}
\scalebox{1.2}{
\begin{tabular}{crc|c|c|c|c|}
\cline{4-7}
\multirow{5}{22.5mm}{\texttt{Individuals}}\ldelim\{{5}{.8mm}
&& &$a_{11}$&    $a_{12}$  &\dots  &$a_{1J}$  \\ \cline{4-7}
&&  &$a_{21}$& $a_{22}$ &\dots  &$a_{2J}$  \\ \cline{4-7}
&&  &$a_{31}$&$a_{31}$  &\dots  & $a_{3J}$ \\ \cline{4-7}
&&  &\vdots & \vdots &\ldots &\vdots  \\ \cline{4-7}
&&  &$a_{I1}$&$a_{I1}$  &\dots  &$a_{IJ}$  \\ \cline{4-7}
& & \multicolumn{1}{c}{} & \multicolumn{4}{c}{\begin{minipage}[c][20mm][c]{24mm}\begin{center}$\underbrace{\hspace*{27.5mm}}$\\\texttt{Attributes} \\ \texttt{$J$ Elements} \end{center} \end{minipage}} \\
\end{tabular}
}
\end{center}
\end{table}


This is the output:

I have two issue:

1. I'd like to have the matrix centered under the caption and not all the stuff, so that individuals and the left bracket would be on the left
2. I'd like to have less distance between the left bracket and the matrix

Use the simple array:

\documentclass{article}
\usepackage{caption}% For space under caption
\begin{document}

\begin{table}
\caption{Invidual/Attributes Matrix}
\centering
\makebox[0pt][r]{\texttt{Individuals}}
$\left\{\rule{0pt}{1.4cm}\right.% \underbrace{\begin{array}{|c|c|c|c|}\hline a_{11} & a_{12} &\dots &a_{1J} \\ \hline a_{21} & a_{22} &\dots &a_{2J} \\ \hline a_{31} & a_{31} &\dots & a_{3J} \\ \hline \vdots & \vdots &\ldots &\vdots \\ \hline a_{I1} & a_{I1} &\dots &a_{IJ} \\ \hline \multicolumn{1}{c}{\vspace{-0.6\normalbaselineskip}} \end{array}}_{\texttt{\normalsize\shortstack{~\\Attributes\\$J$Elements}}}$
\end{table}

\end{document}


You can store the matrix in a box and use it for measurements of the height when placing the Individuals label. Also, for placing the matrix in the horizontal centre of the caption, set the Individuals label inside a zero-width box.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{table}
\caption{Invidual/attributes Matrix}
$\sbox0{% Store the matrix in a box \begin{array}{ | c | c | c | c | } \hline a_{11} & a_{12} & \dots & a_{1J} \\ \hline a_{21} & a_{22} & \dots & a_{2J} \\ \hline a_{31} & a_{32} & \dots & a_{3J} \\ \hline \vdots & \vdots & \ddots & \vdots \\ \hline a_{I1} & a_{I2} & \dots & a_{IJ} \\ \hline \end{array}% } \underbrace{ \makebox[0pt][r]{ \texttt{Individuals} \left\{ \vphantom{\usebox0} \right. \kern-\nulldelimiterspace% } \usebox0 }_{ \begin{tabular}{ c } \ttfamily Attributes \\ \ttfamily J elements \end{tabular} }$

\end{table}


With some measuring:

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

\begin{document}

\begin{table}[htp]

\caption{Invidual/Attributes Matrix}

$\sbox0{% \texttt{Individuals }% \left\{\begin{array}{@{}c@{}}\\\\\\\\\end{array}\right.% } \underbrace{\kern-\wd0 \texttt{Individuals }\left\{ \begin{array}{|c|c|c|c|} \hline a_{11} & a_{12} & \dots & a_{1J} \\ \hline a_{21} & a_{22} & \dots & a_{2J} \\ \hline a_{31} & a_{32} & \dots & a_{3J} \\ \hline \vdots & \vdots & \ddots & \vdots \\ \hline a_{I1} & a_{I2} & \dots & a_{IJ} \\ \hline \end{array}\right. }_{\begin{tabular}{@{}>{\ttfamily}c@{}}Attributes \\ J Elements\end{tabular}} \kern-\wd0$

\end{table}

\end{document}