8

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.

  • 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. – Paulo Cereda Jul 14 '15 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 '15 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. – Cecilia Jul 14 '15 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 '15 at 17:16
9

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

|improve this answer|||||
  • 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. – Cecilia Jul 14 '15 at 17:30
  • Neat. What if \begin{spacing}{0} is not tight enough? Negative values don't do anything... – PatrickT Jul 11 '18 at 17:17
1

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.

|improve this answer|||||
  • 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 '18 at 17:21

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.