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 letterS
. Unfortunately, when applied to theX
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 anX
cell, I automatically add an invisible rule under the base line with>{}
.