3

I want to add extra vertical space after table rows on a row per row basis. Consider the following MWE:

\documentclass{article}

\begin{document}

\begin{tabular}{p{3cm}p{5cm}}
  Here...             & ... it works.                  \\[2ex]
  And...              & ... here \newline it does too! \\[2ex]
  But\newline here... & ... it does not.               \\[2ex]
  Some more text.     & Even more text.
\end{tabular}

\end{document}

In the first two lines, everything is fine. In the third row, however, the multi-line left column swallows the extra space. I want this line to look like if one added \vspace{2ex} right after here....

I thought the optional argument of \\ would add vertical space after the complete row, not only after the last cell. How can I add space below a row without knowing which of the columns is the highest, and without affecting the other rows?

1
  • 1
    You should use \addlineskip[2ex] (or without the optional parameter) of the package booktabs here. This fixes your problem (and we all do like booktabs tables here :-)).
    – LaRiFaRi
    Mar 10, 2015 at 11:44

3 Answers 3

3

A solution using booktabs:

% arara: pdflatex

\documentclass{article}
\usepackage{booktabs}

\begin{document}    
    \begin{tabular}{p{3cm}p{5cm}}
        Here...             & ... it works.                  \\\addlinespace[2ex]
        And...              & ... here \newline it does too! \\\addlinespace[2ex]
        But\newline here... & ... it does not.               \\\addlinespace[2ex]
        Some more text.     & Even more text.
    \end{tabular}   
\end{document}
1
  • 1
    Perfect, that's exactly what I need! I almost always use the booktabs package anyway, but I wasn't aware of this. Thanks! :)
    – einbandi
    Mar 10, 2015 at 11:49
4

Use \noalign{\vspace{2ex}}

\documentclass{article}

\begin{document}

\begin{tabular}{p{3cm}p{5cm}}
  Here...             & ... it works.                  \\[2ex]
  And...              & ... here \newline it does too! \\[2ex]
  But\newline here... & ... it does not.               \\\noalign{\vspace{2ex}}
  Some more text.     & Even more text.
\end{tabular}

\end{document}

enter image description here

1
  • Thank you for this interesting solution. Could you please tell us, why it is working?
    – Jan
    Mar 4, 2022 at 11:11
0

You can use the arraystretch command to alter the spacing between rows. In your case:

\documentclass{article}

 \begin{document}
  \renewcommand\arraystretch{2}
  \begin{tabular}{p{3cm}p{5cm}}
    Here...             & ... it works.                  \\
    And...              & ... here \newline it does too! \\
    But\newline here... & ... it does not.               \\
    Some more text.     & Even more text.
  \end{tabular}
\end{document}

This will yield the following (@LaRiFaRi booktabs solution is added for reference): enter image description here

3
  • Thanks, but my example was probably not the best. I don't necessarily want to add the same space after each column, but rather choose on a row per row basis (as is possible with \addlinespace[]).
    – einbandi
    Mar 10, 2015 at 12:12
  • I see. But why don't you just change the \\[2ex] to a larger value (say \\[5ex]) for the row that is causing the problem?
    – jak123
    Mar 10, 2015 at 12:20
  • That's what I did so far, but it requires a lot of fiddling around to get the right value, since the height of the "tallest" cell is unknown.
    – einbandi
    Mar 10, 2015 at 12:22

You must log in to answer this question.

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