1

I want to use the array package to create a fixed width table with text ragged right, analogous to this question. Unfortunately, even just including the array package breaks the ability to define custom spacings between rows (see example below).

How can I use the array package but still define custom spacings between rows?

\documentclass{article}

\usepackage{array}

\begin{document}

\begin{tabular}{\textwidth}{p{10cm}} A simple line. \[1cm] A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. \[1cm] \textbf{There should be more space before this line}. \end{tabular}

\end{document}

enter image description here

Removing the line \usepackage{array} gives the expected result:

enter image description here

Peter
  • 485

3 Answers3

1

The fact that it appeared to work without array is due to a misfeature of the original implementation fixed in the package. The \\[..] syntax adds extra depth to the row, in the original implementation this is added to the final cell of the table, so although it notionally affects the whole row its effect depends on teh type of the final column, you only get the effect you wanted if the final column is the column with the largest depth. Note if I add an l column at the start of your table you get the spacing you showed, but if I add l column at teh end of the row, the spacing goes.

\documentclass{article}

%\usepackage{array}

\begin{document} \centering

\begin{tabular}{\textwidth}{lp{10cm}} x&A simple line. \[1cm] x&A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. \[1cm] x&\textbf{There should be more space before this line}. \end{tabular}

\bigskip

\begin{tabular}{\textwidth}{p{10cm}l} A simple line.&x \[1cm] A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines.&x \[1cm] \textbf{There should be more space before this line}.&x \end{tabular}

\end{document}

enter image description here

You could increase the length argument so that it is deeper than the depth of the p column, however the booktabs spacing commands provide a better interface here, as you found.

David Carlisle
  • 757,742
0

A possible solution I found based on a related question is \addlinespace from the booktabs package:

\documentclass{article}

\usepackage{booktabs} \usepackage{array}

\begin{document}

\begin{tabular}{\textwidth}{p{10cm}} A simple line. \ \addlinespace[1cm] A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. \ \addlinespace[1cm] \textbf{There should be more space before this line}. \end{tabular}

\end{document}

Peter
  • 485
0

An alternative solution with tblr environment of tabularray package: \\[dimen] will always add vertical space below the row in any case.

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{p{10cm}X} A simple line. & Alpha \[1cm] A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. & Beta \[1cm] \textbf{There should be more space before this line}. & Delta \end{tblr}

\bigskip

\begin{tblr}{Xp{10cm}} Alpha & A simple line. \[1cm] Beta & A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. A longer text that spans multiple lines. \[1cm] Delta & \textbf{There should be more space before this line}. \end{tblr}

\end{document}

enter image description here

L.J.R.
  • 10,932