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 would like to increase the vertical space before and after a horizontal rule in a tabu table but want the color that is in the cells below and above the rule to not be broken but continue right throuh the rule.

Here is my attempt. The first horizontal rule (which is green) does not have enough vertical space so I tried a couple of approaches shown in the red and blue horizontal rules but in both those cases I get white space intervening and I want the color to go right through from the cell above to the cell below. In addition the red rule does not really have enough space above and below it anyways. ADDED: The vertical spacing between rows 1 and 2 should not be changed since there is no rule between them. Also it might be that different horizontal rules require different vertical spacing so the spacing should ideally be controllable on a rule by rule basis.

\documentclass{article}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{tabu}
\begin{document}

\begin{center}
\begin{tabu}{X>{\columncolor{blue}}XXX}
1 & 2 & a & b\\
1 & 2 & a & b\\
\tabucline[green]-
1 & 2 & a & b\\
\arrayrulecolor{red}
\cmidrule(r{1.0ex}){1-2}\cmidrule(l{1.0ex}){3-4}
1 & 2 & \cellcolor{green}a & b\\
\addlinespace
\tabucline[blue]-
\addlinespace
1 & 2 & \cellcolor{green}a & b\\
\end{tabu}
\end{center}
\end{document}

Output:

screenshot

share|improve this question
    
do you want to increase the spacing throughout the table or only for certain rows? –  ArTourter Jul 22 '12 at 23:49
    
I only want to increase the vertical space before and after the rules. If there is no horizontal rule then it should be as is. Thus the spacing between the first two rows where there is no horizontal rule have the desired vertical space between them already. –  user1189687 Jul 22 '12 at 23:51
    
I think your problem is the booktabs package, because it handles the rules in package tabu. It does not look for the colors. You can see this by adding for example \setlength{\aboverulesep}{5pt} in your MWE. That is the same space \addlinespace uses. Perhaps mail to the maintainer of booktabs? –  Kurt Jul 23 '12 at 0:34
    
If this can be accomplished without booktabs that would be ok. –  user1189687 Jul 23 '12 at 0:41
1  
@Kurt, I emailed the booktabs package author; however, the author felt that the way it works now (viz. to add space outside of the cells) is intentional and we cannot really expect that to change in the future. It seems Xoff's idea (see accepted answer) of removing the vertical space around rules and expanding the within cell vertical margins is the only way to accomplish this. –  user1189687 Jul 24 '12 at 15:18
show 2 more comments

1 Answer 1

up vote 2 down vote accepted

Is it what you want ?

\documentclass{article}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{adjustbox}
\usepackage{tabu}
\begin{document}
\belowrulesep=0pt
\aboverulesep=0pt

\begin{center}
\begin{tabu}{X>{\columncolor{blue}}XXX}
1 & 2 & a & b\\
1 & 2 & a & b\\
\tabucline[green]-
1 & 2 & a & b\\
\arrayrulecolor{red}
\cmidrule(r{2.0ex}){1-2}\cmidrule(l{2.0ex}){3-4}
\adjustbox{margin=0pt 10pt 0pt 0pt}{1} & 2 & \cellcolor{green}a & b\\
\tabucline[blue]-
\adjustbox{margin=0pt 0pt 0pt 10pt}{1} & 2 & \cellcolor{green}a & b\\
\end{tabu}
\end{center}
\end{document}

This is more a hack than a real solution. I add margin inside the cells with adjustbox, and remove the space around cmidrule ....

share|improve this answer
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.