I am attempting to create a table in which cells of one of the columns contains a nested table as the cell value.
So far I have got this:
\documentclass{article}
\usepackage{array,multirow}
\begin{document}
\begin{table}
\begin{tabular}{|c|cccc|c|}\hline
Col. A & Col. B & & & & Col. C \\ \cline{1-6}
\multirow{4}{*}
{Val. 1}
& & a & b & c \\
& b & 2 & & \\
& c & 2 & 3 & \\
& d & 2 & 3 & 4 \\ \hline
\multirow{4}{*}
{Val. 2}
& & a & b & c \\
& b & 2 & & \\
& c & 2 & 3 & \\
& d & 2 & 3 & 4 \\ \hline
\end{tabular}
\end{table}
\end{document}
which creates something like this:
A few things I want to fix/improve on this:
Despite having only 3 columns, I'd like to extend the table to cover the full width of text on the page?Does not need to span across the whole text width, but outer columns 'A' and 'C' should handle multi-line values comfortably.In
Col. B
, I'd like to "prettify" the inner table structure so that it becomes a 4x4 square shape with equal spacings between rows and columns, and the whole table centered within the cell.How do I center
Col. B
text in the table header, and center the values (possibly multi-line) ofCol. C
both horizontally and vertically in the cell?
If possible, I'd like to use as few extra package as possible. So if this can be done with array
and multirow
(and possibly multicol
), then let's use them only.
UPDATE: thanks to @DavidCarlisle's answer, I produce the following in my output:
How can we make the shape of the nested tables in Col. B
square? Can we set the width of each outer column somehow?