
我编写了这个代码是为了获得一个简单的 I x J 矩阵。
\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}
我有两个问题:
- 我希望矩阵位于标题下方的中心,而不是所有内容,以便个人和左括号位于左侧
- 我希望左括号和矩阵之间的距离更小
答案1
使用简单的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}
答案2
您可以将矩阵存储在一个框中,并在放置标签时使用它来测量高度Individuals
。此外,要将矩阵放置在标题的水平中心,请将标签设置Individuals
在零宽度框内。
\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}
答案3
经过一些测量:
\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}