What to put into the intersection of the row/column labels of a table?
It is also possible to use TikZ directly inside the tabular, needing no savebox at all to get the lenghts:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{table}
\caption{Diagonal Split}
\[\begin{array}{c|ccccc}
\tikz{\node[below left, inner sep=1pt] (def) {def};%
\node[above right,inner sep=1pt] (abc) {abc};%
\draw (def.north west|-abc.north west) -- (def.south east-|abc.south east);}
& 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}
Then, inside the \tikz
command you have the TikZ power to do whatever... Here is a version with repositioned nodes, a very thin
shorten
ed division line and fonts in \footnotesize
.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{table}
\caption{Diagonal Split}
\[\begin{array}{c|ccccc}
\tikz[diag text/.style={inner sep=0pt, font=\footnotesize},
shorten/.style={shorten <=#1,shorten >=#1}]{%
\node[below left, diag text] (def) {def};
\node[above right=2pt and -2pt, diag text] (abc) {abc};
\draw[shorten=4pt, very thin] (def.north west|-abc.north west) -- (def.south east-|abc.south east);}
& 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}
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.
\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}
Here are two options:
\documentclass{article}
\usepackage{mathtools,eqparbox}
\newcommand{\indices}[2]{{% \indices{<rows>}{<columns>}
\begin{array}{@{}r@{}}
\scriptstyle #2~\smash{\eqmakebox[ind]{$\scriptstyle\rightarrow$}} \\[-\jot]
\scriptstyle #1~\smash{\eqmakebox[ind]{$\scriptstyle\downarrow$}}
\end{array}}}
\begin{document}
\[
\begin{array}{c|ccccc}
\indices{\text{abc}}{\text{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}
\]
\[
\begin{array}{cc|ccccc}
&\multicolumn{1}{c}{} & \multicolumn{5}{c}{\text{def}} \\
&& 1 & 2 & 3 & 4 & 5 \\
\cline{2-7}
& 1 & a & b & c & d & e \\
\smash{\rotatebox[origin=c]{90}{\text{abc}}} & 2 & f & g & h & i & j \\
& 3 & k & l & m & n & o
\end{array}
\]
\end{document}
If you're interested in a matrix-like command, there are some examples at Where is the \matrix
command?. This includes using \bordermatrix
, kbordermatrix
and blkarray
, all of which allows you to place indices to identify the rows/columns.