3

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

  • 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
  • If this can be accomplished without booktabs that would be ok. – user1189687 Jul 23 '12 at 0:41
  • If you want a thick line you can use \tabucline[3pt]- and eliminating the \addlinespace produces a thick red line without any white space above or below. – Peter Grill Jul 23 '12 at 3:47
  • I want vertical space above and below the line as opposed to a thicker line. – user1189687 Jul 23 '12 at 10:43
2

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 ....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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