10

I used the suggestion from Adding row spacing to a longtable? to decrease the row spacing in my longtable.

\documentclass{article}
\usepackage{longtable}
\begin{document}

\renewcommand{\arraystretch}{0.7}
\begin{longtable}{ l | l | l }
    a & b & a small phrase \\
    a & b & a small phrase \\
    a & b & a small phrase
\end{longtable}

\end{document}

produces

Example screenshot of working code

But if I have a p column

\documentclass{article}
\usepackage{longtable}
\begin{document}

\renewcommand{\arraystretch}{0.7}
\begin{longtable}{ l | l | p{5 cm} }
    a & b & a small phrase \\
    a & b & a small phrase \\
    a & b & here is a long sentence which wraps to the next line \\
    a & b & a small phrase
\end{longtable}

\end{document}

The spacing between the lines of the paragraph doesn't get reduced.

Example screenshot of problem

How can I also reduce the spacing between the paragraph lines?

I also read Longtable with multicolumn and parbox spacing issues, but the example was so complex, I wasn't sure whether the problem was the same at all.

4
  • The line spacing wasn't reduced because it is not related to \arraystretch. :) Maybe \linespread{<value>} could be of use, but I'm not too keen on this table layout. Jul 14, 2015 at 16:34
  • Do you have serious reasons to decrease rowspacing. Generally, latex tables are considered having a very tight spacing, and can easily be hard to read.
    – Bernard
    Jul 14, 2015 at 16:38
  • @Bernard My actual table covers three pages with the default longtable spacing. I thought imitating the default spacing of tabular would make it more compact and easier to scan.
    – 2cents
    Jul 14, 2015 at 17:11
  • @Cecilia: Another solution consists in reducing the font size to, say, \footnotesize. Inside a paragraph cell, use \linespread{…}as mantioned by @Paulo Cereda, or (perhaps better) \setstretch{…}, from the setspace package.
    – Bernard
    Jul 14, 2015 at 17:16

2 Answers 2

10

You can also set line spacing locally in a clean way as this:

\documentclass{article}
\usepackage{longtable}
\usepackage{setspace}
\begin{document}

\begin{spacing}{.7}
\begin{longtable}{ l | l | p{5 cm} }
    a & b & a small phrase \\
    a & b & a small phrase \\
    a & b & here is a long sentence which wraps to the next line, here is a long sentence which wraps to the next line \\
    a & b & a small phrase
\end{longtable}
\end{spacing}

\end{document}

enter image description here

2
  • I like this solution best because I can use the spacing 1.0 and get exactly the same spacing as the rest of the document. I don't have to figure out the conversion for the default longtable row spacing.
    – 2cents
    Jul 14, 2015 at 17:30
  • Neat. What if \begin{spacing}{0} is not tight enough? Negative values don't do anything...
    – PatrickT
    Jul 11, 2018 at 17:17
4

For some reason I didn't like the output of the setspacing package, and struggled to find that simply modifying \baselineskip would do. Maybe this can help people in the future:

\documentclass{article}
\usepackage{longtable}
\usepackage{array} %<================= Added this

\begin{document}

%\renewcommand{\arraystretch}{0.7}
\begin{longtable}{ l | l | >{\baselineskip=10pt}p{5 cm} }
    a & b & a small phrase \\
    a & b & a small phrase \\
    a & b & here is a long sentence which wraps to the next line \\
    a & b & a small phrase
\end{longtable}

\end{document}

The notation >{declaration} add declaration before every instance of the p{} column. Also, notice that I added the array package.

1
  • 1
    Very neat. You can also define a column type like so (for instance): \newcolumntype{L}[1]{>{\flushleft\arraybackslash}>{\baselineskip=0pt}p{#1}} Sadly it won't take negative spacing and, for some reason, zero spacing is not tight enough for me...
    – PatrickT
    Jul 11, 2018 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .