# In nested tables, how can I make an inner table stretch to fit its column?

I'm trying to design a layout that has tables nested within tables, and I'm having trouble getting things to line up. The question is quite similar to How to make width of an inner table use full column width of an outer table? except that I have no tabularx involved---I am looking to get the table itself to stretch. I imagine that a solution will have two components:

• Some stretchiness to \tabcolsep
• Some way of telling the outer table not to fill on the left and right sides

I have not been able to figure out how to achieve such an effect.

Here is a minimal working example:

\documentclass{article}
\begin{document}
\begin{tabular}{cc}
A relatively wide line& Thin \\
\begin{tabular}{@{}ll@{}}
\hline
A&B\\
\hline
C&D\\
\hline
\end{tabular}&
Thicker\\
The ABCD table should stretch to fit&Thickest\\
\end{tabular}
\end{document}


The resulting table looks like

but what I want is for the ABCD table to stretch the full width of its column (even though that would look awful in this case).

What I am actually trying to accomplish can be illustrated by considering the misalignments in the following non-minimal example:

Two of the outcomes I would like are

• Section E stretches automatically to become the same width as section D
• Section G stretches automatically to become the same width as what's above it

Does anyone have ideas about how this might be accomplished?

If you want stretching, you can't use a tabular.

\documentclass{article}
\newlength{\columnA}
\newlength{\columnB}
\newsavebox{\tempbox}
\begin{document}

\settowidth{\columnA}{The ABCD table should stretch to fit}
\settowidth{\columnB}{Thickest}

\savebox{\tempbox}{%
\parbox[t]{\columnA}{\centering
A relatively wide line\\
\rule[1.5ex]{\columnA}{.5pt}\vspace{-1.5ex}
A \hfil B\\
\rule[1.5ex]{\columnA}{.5pt}\vspace{-1.5ex}
C \hfil D\\
\rule[1.5ex]{\columnA}{.5pt}\vspace{-1.5ex}
The ABCD table should stretch to fit}%
}%
\usebox{\tempbox}\hspace{\columnsep}%
\parbox[t][\dimexpr \ht\tempbox + \dp\tempbox][s]{\columnB}{\centering
Thin\vfill
Thicker\vfill
Thickest}

\end{document}


• Too depressing. There must be a way to do it. \settowidth is not a bad trick, though. – Norman Ramsey May 31 '15 at 17:01