# Oversize table with nested tabularx->minipage->tabular* has columns that are too narrow (Memoir)

I am trying to lay out a table heading that looks something like this:

      TITLE
---------------------      subtitle
Name  Value             description
Name  A value of         Name  Value
some length        Name  Value


Where Name and Value are arbitrary pairs of values (and value may be somewhat lengthy).

In my circumstances this layout is better set at a width greater than the background \textwidth. Unfortunately that seems to be the cause of an issue because in my layout the inner tables, containing Name/Value, are too narrow. The issue may be elsewhere, for example a problem with nesting tables - though the memoir package documentation specifically advises that nesting should be okay, save a workaround when tabularx environments are nested – not the case here.

Here is an example demonstrating the issue, with vertical lines added to the tabular environments for illustration:

\documentclass[oneside,12pt]{memoir}
\usepackage{ragged2e}
\usepackage{lipsum}

\begin{document}
\hspace{-3cm}%
\begin{tabularx}{14cm}[t]{l |X|}
\fbox{\begin{minipage}{9cm}%
\centering
{\Large Title}\\\medskip
\RaggedRight
\begin{tabular*}{9cm}{|r|X|}
\toprule
Name & Value \\
Name & This is a long value that will wrap a couple of lines.\\
\bottomrule
\end{tabular*}
\end{minipage}} & %
\begin{minipage}{6cm}
\RaggedRight
\begin{center}Subtitle\end{center}
\textit{Description under the title}\\\bigskip
\begin{tabular*}{\linewidth}{rl}
Name & Some value\\
Name & Value\\
\end{tabular*}
\end{minipage}
\end{tabularx}
\end{document}


As you can see the effect is something like:

      TITLE
---------------------         subtitle
Name | Value  |            description
Name | A value|            Name  Value
| of some|            Name  Value
|  length|


I seem to be able to get to something closer to the desired effect by giving all the tabular columns particular widths with p{}, though I have not yet worked it out and I expect there is a more elegant and dynamic solution than hard-coding everything (...but perhaps not).

I am using the Memoir package, and would enjoy thoughts on how to achieve the above using that package.

• This isn't really related to memoir at all. I'm not quite sure as to what it is you want to do. – daleif Jun 12 '13 at 13:21
• @daleif The memoir package has defined its own tabular{,*,x} commands and other peculiarities that may affect the outcome, so it seemed necessary to mention it. – Brian M. Hunt Jun 12 '13 at 14:48
• They are more or less carbon copies of the code from the corresponding packages so I do not think there is anything related to memoir in the code above, using say, article plus tabularx would give you the same result. – daleif Jun 12 '13 at 15:04

It isn't really clear what you want to do (and you can't use X in a tabular*) however the markup here is a lot simpler and it might be close to the layout you want....

\documentclass[oneside,12pt]{memoir}
\usepackage{ragged2e}
\usepackage{lipsum}

\begin{document}
\hspace{-3cm}%
\begin{tabularx}{\dimexpr(\textwidth+2cm)/2\relax}[t]{|l |X|}
\toprule
\multicolumn{2}{c}{\Large Title}\\
\hline
Name & Value \\
Name & This is a long value that will wrap a couple of lines.\\
\bottomrule
\end{tabularx}\hfill
\begin{tabularx}{\dimexpr(\textwidth+2cm)/2\relax}[t]{|l |X|}
\toprule
\multicolumn{2}{c}{Subtitle}\\
\multicolumn{2}{l}{\textit{Description under the title}}\\
\hline
Name & Some value\\
Name & Value\\
\bottomrule
\end{tabularx}

\bigskip

\noindent X\dotfill X
\end{document}

• Thank you David - that's exactly what I was looking for - a little illumination into how one might go about this sort of thing! Very much appreciated. – Brian M. Hunt Jun 13 '13 at 12:27

Here is an example of hard-coding the widths:

 \hspace{-3cm}%
\begin{tabularx}{18cm}[t]{p{10cm} p{7cm}}
\begin{minipage}{\linewidth}%
\centering{\Large Title}\\\medskip
\begin{tabular}{R{2cm} L{\linewidth - 3cm}}
\toprule
Name & Value \\
Name 2 & This is Hello,world, how long %
does this have to be? a long value %
that will wrap a couple of lines.\\%
\bottomrule
\end{tabular}
\end{minipage}%
& %
\begin{minipage}{\linewidth}
\noindent\begin{center}
Subtitle\\
\textit{Description under the title}
\end{center}
\begin{tabular*}{6cm}{R{2cm} L{4cm}}
Name & Some value\\
Name & Value\\
\end{tabular*}
\end{minipage}\\
\end{tabularx}


As mentioned, it would be nice to solve this in a more dynamic and elegant way (i.e. if one were to change the width of one column the rest would adjust accordingly).

• Couldn't you just use \linewidth as the width of the two minipages (untested)? Then at least their widths only depend on the p{...}. – daleif Jun 12 '13 at 13:20
• @daleif Great tip; updating. – Brian M. Hunt Jun 12 '13 at 14:49