# How to make (nested) tabularx and multirow play nicely together?

I'm trying to make a layout with 3 independent columns. Following answers this question I have tried using tabularx and multirow to make it work. I seem to be nearly there:

However I have two issues:

1) How can I make the text in the 3rd (rightmost) column start at the same level as the top of the graphics? If I have to do it manually with a fixnum is there a way of calculating the required value?

2) Why does the text in the third column not seem to respect the multirow? (and why is there a white line)

Two other issues are:

• In the first column, why are "Item 1" and "Item 2" not raggedleft whereas "item 3" is? How can I fix that?

• The left edge of the graphics does not align with the left edge of column 1 - is there a way to do that?

Here is my minimal example:

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[oneside,english,oldfontcommands,a4paper]{memoir}
\usepackage{fontspec}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{colortbl}
\definecolor{grey}{HTML}{F4F4F4}
\usepackage{multirow}
\usepackage{lipsum}

\makeatother

\usepackage{babel}
\begin{document}
\renewcommand{\tabularxcolumn}[1]{p{#1}}

\noindent\begin{tabularx}{\linewidth}{@{}>{\hsize=1.5\hsize}X|>{\hsize=0.5\hsize\columncolor{grey}}X@{}}
\rule{1.5\linewidth}{0.15\textheight}
&
\multirow{3}{0.5\linewidth}{\lipsum[1]} \tabularnewline  \tabularnewline

{\noindent\begin{tabularx}{1.5\linewidth}{@{}>{\hsize=0.5\hsize\footnotesize\raggedleft\arraybackslash\columncolor{grey}}X|>{\hsize=1.5\hsize}X@{}}
Item 1 \newline Item 2 \newline Item 3 & \lipsum[1-3]   \end{tabularx}}
&
\tabularnewline

\rule{1.5\linewidth}{0.15\textheight}
&
\tabularnewline
\end{tabularx}

\clearpage
\end{document}


Ok, so following comments from @DavidCarlisle below. Here is a simpler example. I have set the rightmost column in the outer tabularx to p{0.2\linewidth}. This means that the rules and inner tabularx work with a width of \linewidth. I have also removed the \columncolor{grey} from the outer tabularx as it seems the grey fill was getting printed on top of the text. So the issues that still remain are 1) aligning the text in the right column of the tabularx with the top of the rule and 2) aligning the left edge of the rules with the left column of the inner tabularx. Revised MWE:

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[10pt,oneside,english,oldfontcommands,a4paper]{memoir}
\usepackage{fontspec}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=1cm,bmargin=1cm,lmargin=1cm,rmargin=1cm}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{colortbl}
\definecolor{grey}{HTML}{F4F4F4}
\usepackage{multirow}
\usepackage{lipsum}

\makeatother

\usepackage{babel}
\begin{document}
\renewcommand{\tabularxcolumn}[1]{p{#1}}

\noindent\begin{tabularx}{\linewidth}{@{}X|p{0.2\linewidth}@{}} \rule{\linewidth}{0.15\textheight}  &  \multirow{3}{\linewidth}{\lipsum[1]} \tabularnewline  \tabularnewline
{\noindent\begin{tabularx}{\linewidth}{@{}>{\hsize=0.5\hsize\footnotesize\raggedleft\arraybackslash\columncolor{grey}}X|>{\hsize=1.5\hsize}X@{}} Item 1 \linebreak Item 2 \linebreak Item 3 \linebreak & \lipsum[1-3]   \end{tabularx}} &  \tabularnewline
\rule{\linewidth}{0.15\textheight} & \tabularnewline   \end{tabularx}
\clearpage \end{document}

\clearpage
\end{document}


Which gives me:

Ok. I can align the rule with the edge of the column by doing: \hspace{-\tabcolsep}\rule{\linewidth+\tabcolsep}{0.15\textheight}

So aligning the text with the top of the rule is now the issue remaining.

-

The baseline of a rule or graphic by default is at the bottom, you could put something before it for example \null would make the text align with an empty box above the rule, although that may make it look too high as the baseline of the text then aligns with the top of the rule. You may prefer to use \raisebox to give the graphic depth rather than height you can use \height etc to refer to the original dimensions. (I believe the adjustbox package simplifies some of that.
Nothing to do with tables but \newline doesn't do what you want in \raggedleft normally you could use \\ but as you've reset that back to the table version you can use \linebreak
You are specifying \rule{1.5\linewidth} ie specifying a rule that doesn't fit as it is too large by 50%, I'm not sure quite what you want the behaviour to be?
I'd have to think what exactly happens if you use \linewidth like that, but whatever happens it's accidental and probably bad. LaTeX p columns (including tabularx X columns) set \linewidth locally to the (current attempted target) width of the cell. So whatever width tabularx tries to set for the column, you are putting in a rule 1 and a half times bigger than that. – David Carlisle Mar 23 '12 at 9:24