0

I am working on a table where I need to add extra space between groups of rows. I have currently been doing this by ending all but the last row within a group with \\* (which prevents a page break at the end of the row on which it is used). The last row in each group ends with \\[\ExtraRowSpace] where \ExtraRowSpace is some length (e.g., 2cm).

The only problem with this approach is that, at the end of every page of the table (except the last one), there is an annoying gap between the last row of data and the \bottomrule. Is there any way that I can conditionally insert extra space between groups of rows in my table so that the space is not added just before a page break?

The following document gives a simple demonstration of the problem:

\documentclass[12pt]{article}
\usepackage{longtable}
\usepackage{booktabs}
\newcommand{\ExtraRowSpace}{2cm}
\begin{document}
\begin{center}
\begin{longtable}{cccc}
\toprule
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} \\
\midrule
\endfirsthead
\toprule
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} \\
\midrule
\endhead
\bottomrule
\endfoot
\bottomrule
\endlastfoot
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d
\end{longtable}
\end{center}
\end{document}
1

The problem can be fixed by using a feature of the booktabs package. Simply replace each use of \\[2cm] by \\ \addlinespace[2cm]. Using the \addlinespace command allows booktabs to remove the extra space at the end of a page. Here is a fixed version of the document:

\documentclass[12pt]{article}
\usepackage{longtable}
\usepackage{booktabs}
\newcommand{\ExtraRowSpace}{2cm}
\begin{document}
\begin{center}
\begin{longtable}{cccc}
\toprule
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} \\
\midrule
\endfirsthead
\toprule
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} \\
\midrule
\endhead
\bottomrule
\endfoot
\bottomrule
\endlastfoot
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d \\ \addlinespace[\ExtraRowSpace]
a & b & c & d \\* a & b & c & d \\* a & b & c & d \\* a & b & c & d
\end{longtable}
\end{center}
\end{document}

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.