Graphics, Figures & TablesChanging table row spacing in booktabs/longtable

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
matlock
Posts: 1
Joined: Thu Jun 24, 2010 10:46 pm

Changing table row spacing in booktabs/longtable

Post by matlock »

I'd like to be able to add spacing between all of the rows while still using the booktabs and longtable packages. It seems like the tabls package would allow me to do this with

Code: Select all

\setlength\tablinesep{10pt}
but inclusion of the tabls package causes tons of errors when used with the following example.

Code: Select all

\documentclass{article}

\usepackage{booktabs,longtable}

\begin{document}

\begin{longtable}{l p{0.35\textwidth} @{\hspace{2em}} p{0.375\textwidth}}
% first page's table head
\toprule
ISBN & Title & Description \\
\midrule
\endfirsthead
9780201362992 & The \LaTeX\ Companion & A very helpful book about \LaTeX\ written by the developers of many widely-used packages. \\
9780201134476 & Computers and Typesetting, Vol. A: The \TeX book & Written by The Man Himself (Don K.). \\
9780471309321 & Classical Electrodynamics (3rd. Ed.) & One of these is not like the others. \\
\bottomrule
\end{longtable}

\end{document}
Having to write \\[\defaultaddspace] at the end of each line is clearly a gross solution, so that's out.

It occurs to me that I could do something like

Code: Select all

\newcommand\eor{\\ \addlinespace[10pt]}
and end all lines except for the last one with \eor instead of \\ (eor = end of row), but that seems inelegant.

By the way, is there a way to write code inline on this board, or am I better off just leaving small code fragments in plain text?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Changing table row spacing in booktabs/longtable

Post by localghost »

The quite new tabu package offers a solution with the length \tabulinesep. You can modify it as desired.

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{booktabs,longtable,tabu}

\setlength{\tabulinesep}{3pt}

\begin{document}
  \begin{longtabu}{l p{0.35\textwidth} @{\hspace{2em}} p{0.375\textwidth}}\toprule
    % first page's table head
    ISBN & Title & Description \\ \midrule
    \endfirsthead
    9780201362992 & The \LaTeX\ Companion & A very helpful book about \LaTeX\ written by the developers of many widely-used packages. \\
    9780201134476 & Computers and Typesetting, Vol. A: The \TeX book & Written by The Man Himself (Don K.). \\
    9780471309321 & Classical Electrodynamics (3rd. Ed.) & One of these is not like the others. \\ \bottomrule
  \end{longtabu}
\end{document}
Note that the longtable package needs to be loaded explicitly.


Thorsten
Post Reply