[Tex/LaTex] What to put into the intersection of the row/column labels of a table

spacingtablestypography

I have a grid/table/matrix with separate labels for the rows and the columns. However, I also want to label these labels themselves (by indicating the "type" of the labels, such as SI units, etc.)

Here is a MWE, with three variants (check the entry abc/def in the upper left position, describing the row labels abc and the column labels def):

\documentclass{article}
\begin{document}
\begin{table}
\caption{Forward slash.}
\[\begin{array}{c|ccccc}
abc/def & 1 & 2 & 3 & 4 & 5\\
\hline
1 & a & b & c & d & e\\
2 & f & g & h & i & j\\
3 & k & l & m & n & o\\
\end{array}\]
\end{table}

\begin{table}
\caption{Vertical bar.}
\[\begin{array}{c|ccccc}
abc|def & 1 & 2 & 3 & 4 & 5\\
\hline
1 & a & b & c & d & e\\
2 & f & g & h & i & j\\
3 & k & l & m & n & o\\
\end{array}\]
\end{table}

\begin{table}
\caption{Backslash.}
\[\begin{array}{c|ccccc}
abc\backslash def & 1 & 2 & 3 & 4 & 5\\
\hline
1 & a & b & c & d & e\\
2 & f & g & h & i & j\\
3 & k & l & m & n & o\\
\end{array}\]
\end{table}

\end{document}

enter image description here

However, this MWE suffers from (at least) the following two problems: the first column (labelling the rows) is too wide, and the centered labels are far from the core of the array itself (right-aligning could help, but… that introduces other problems). Second, the spacing around abc/def looks incorrect.

The questions is, basically, how should I typeset this array nicely? What should I put to the upper left position, in place of abc/def? I do not wish to put abc and def into two distinct (multi)columns. Maybe stacking abc above (or under?) def is a start, but then I would still need some kind of visual separator (taking the role of the \|/ symbols) within that cell. I should probably also clarify that both labels abc and def are in practice very short, typically I would write x/y or n/m or n/k, so single-character mathematical variables, and not lengthy texts.


Related: How to create table with labels (first row and first column)

Best Answer

I'm going to suggest "none of the three possibilities". Instead, consider using a classic "tableau" setup, with a clear hierarchical structure in the header. Such a setup helps avoid creating the "cramped" look that's almost inevitable with any one of the three possibilities you've offered.

enter image description here

\documentclass{article}
\usepackage{booktabs}% for \toprule, \midrule, \bottomrule, and \cmidrule macros
\usepackage{amsmath} % for \text macro
\begin{document}
\begin{table}
\caption{Still another approach}
\[
\begin{array}{@{}l*{5}{c}@{}}
\toprule
\text{abc} & \multicolumn{5}{c@{}}{\text{def}}\\
    \cmidrule(l){2-6}
    & 1 & 2 & 3 & 4 & 5\\
\midrule
1 & a & b & c & d & e\\
2 & f & g & h & i & j\\
3 & k & l & m & n & o\\
\bottomrule
\end{array}
\]
\end{table}
\end{document}