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.

In the following code the horizontal rules on the right don't line up in all cases with the horizontal rules on the left. It seems to be related to the text content. How can I fix this in such a way that it works regardless of what the text is. Thanks.

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}

\setlength{\columnseprule}{.4pt} 
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\tabulinesep=4pt\begin{tabu} to \columnwidth{>{\bfseries}lX} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
\end{tabu} 
\tabulinesep=4pt\begin{tabu} to \columnwidth{>{\bfseries}lX} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & more / words \\ 
Some words & and some more \\ 
\end{tabu} 
\end{multicols} 
\end{document}

Output looks like this:

screenshot

ADDED:

David Carlisle brought up the issue of multiline content so using his code I tried this. Note that it does not line up. It may be that cases such as this where there is multiline content cannot be aligned in a general way but if it is possible it would be interesting to know how to do it.

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}

\setlength{\columnseprule}{.4pt} 
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
\end{tabu} 
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words &  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu- lum ut, placerat ac, adipiscing vitae, felis. \\
Some words & and some more \\ 
Some words & more / words \\ 
Some words & and some more \\ 
\end{tabu} 
\end{multicols} 
\end{document}

which gave this:

screenshot

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

You need to make sure the text on the first and last line is at least as high/deep as a strut. Also you need to \noindent before your table as otherwise you try to squeeze a full width table and a paragraph indent on to the same line and get 15pt overfull each time.

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{multicol}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}

\setlength{\columnseprule}{.4pt} 
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut\fi}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
\end{tabu} 
\tabulinesep=4pt
\noindent
\begin{tabu} to \columnwidth{>{\bfseries}l>{\strut\ignorespaces}X<{\ifhmode\unskip\strut\fi}} 
\everyrow{\tabucline[blue]-}
Some words & and some more \\ 
Some words & and some more \\ 
Some words & and some more \\ 
Some words & more / words \\ 
Some words & and some more \\ 
\end{tabu} 
\end{multicols} 
\end{document}
share|improve this answer
    
Thanks. I tried reducing your \begin{tabu} line to \begin{tabu} to \columnwidth{>{\bfseries}l>{\strut}X} and at least on this example it seemed ok. Can you explain what the other portions of that line do? –  user1189687 Aug 6 '12 at 13:32
1  
the X columns are potentially multi-line (otherwise there is no pint in using X) If you have a 3-line X entry then a strut in the first l column won't affect its depth, so you need a strut at the start of the cell and the end. –  David Carlisle Aug 6 '12 at 13:45
    
I tried a multiline example (see new section in post called ADDED); however, in that case it seems it does not line up. Not sure if its even possible in that case. –  user1189687 Aug 6 '12 at 14:06
1  
well it would line up if (say) every X entry were 2 lines. If the entries are irregular then TeX doesn't really do grid typesetting. You could work harder to ensure that the table line spacing was equal to the normal linespacing (so no extra space for the table rows or horizontal rule) but doing it in general (eg if you include graphics into the table it gets harder still) –  David Carlisle Aug 6 '12 at 14:12
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.