[Tex/LaTex] Increase vertical row spacing in booktabs, but keep content vertically centered

spacingtablestabularx

I am using tabularx + booktabs and I am looking for a way to increase the vertical spacing between rows, but at the same time keep the content of each row vertically centered.

I have tried to use arraystretch but, as shown in this answer, the additional space is not evenly distributed; more space tends to be added to the 'top' of the row than to the bottom.

I would like to find a solution that affects all rows in all tables of a document (which has dozens of long tables) without having to manually insert spaces, struts, etc. for each individual row.

More details: I am not using midrules to separate individual rows. I am relying on \rowcolor to differentiate rows.

Here's a MWE taken from egreg's answer:

\documentclass{article}
\usepackage{tabularx,booktabs}
\usepackage{lipsum} % just for the example

\usepackage[table]{xcolor}
\rowcolors{2}{gray!10}{white}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{}llX@{}}
\toprule
A & B & \centering C \tabularnewline
\midrule
1 & 2 & \lipsum*[2] \\

1 & 2 & \lipsum*[2] \\
\bottomrule
\end{tabularx}

\bigskip

\noindent
\begin{tabularx}{\textwidth}{@{}llX@{}}
\toprule
A & B & \centering C \tabularnewline
\midrule
1 & 2 & \lipsum*[2] \\

1 & 2 & \lipsum*[2] \\
\bottomrule
\end{tabularx}

\end{document}

Is this possible?

Best Answer

A simple solution would be to use the cellspace package, which defines minimal spacing at the top and bottom of cells in columns with specifier prefixed with the letter S. Unfortunately, when applied to the X column type and `colortbl is loaded, it doesn't work any more, for some reason.

So I had to use a work-around: cellspace is used for the first column, and at the end of an X cell, I automatically add an invisible rule under the base line with >{}.

\documentclass{article}
\usepackage{tabularx,booktabs}
\usepackage{lipsum} % just for the example
\usepackage{bigstrut}
\usepackage[table, svgnames]{xcolor}
\usepackage{cellspace}
\setlength\cellspacetoplimit{1.5ex}
\setlength\cellspacebottomlimit{1.5ex}
\rowcolors{2}{lightgray!30!Lavender}{white}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{Sl l X <{\rule[-2ex]{0pt}{0ex}}}%
\toprule
\rowcolor{white}
A & B &\multicolumn{1}{c}{C} \tabularnewline
\midrule
1 & 2 & \lipsum*[2] \\ %
1 & 2 & \lipsum*[2] \\ %
1 & 2 & \lipsum*[2] \\
\bottomrule
\end{tabularx}

\end{document}

enter image description here