Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

Pagelayout

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}
\pagestyle{myheadings}
\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}
\setheadfoot{3cm }{ 0.1cm }
\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}
\pagestyle{myheadings}
\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}
\setheadfoot{3cm }{ 0.1cm }
\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: revised layout

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.

share|improve this question
add comment

1 Answer

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?

share|improve this answer
    
The \linebreak sorts out my \raggedleft, thanks. The 1.5\linewidth is empirical - that is what fits. If I use \TX@col@width for the width of the inner tabularx or the rules, it ends up being approx 1/2 of the overall text block width. It seems \linewidth is redefined somewhere. –  user8786 Mar 23 '12 at 7:48
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.