4

I create a table using the tabularx environement for automatic line breaking. I also enlarged the space between some rows (not all) with the command \\[<m>pt] where <m> is a number.

\documentclass{article}
\usepackage{tabularx}
\begin{document}
    \begin{tabularx}{\textwidth}{lX}
    row1 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        \\[4pt]
    row2 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        \\
    row3 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{tabularx} 
\end{document}

Although the instruction \\[4pt] works fine with tabular, it doesn't work with tabularx. How to handle parameterized space for some rows of a tabularx environment ?

5
  • 3
    Please, be so kind and extend your code snippet to complete small document )(MWE: Minimal Working Example). It is not fun to preamble of your document, which you not share with us. Your problem can be solved for example by use of \addlinespace from booktabs package. To show you how, we need your MWE.
    – Zarko
    Jan 9, 2020 at 19:45
  • 2
    Are we supposed to assume that where you wrote "long text", there's actually a multi-line paragraph? Please confirm.
    – Mico
    Jan 9, 2020 at 20:05
  • With the information provided so far, the issue is not reproducible. Therefore, please prepare a complete minimal working example (MWE).
    – leandriis
    Jan 9, 2020 at 20:18
  • 1
    It also does not work with \begin{tabular}{lp{10cm}}. However, \addlinespace[4pt], as also suggested by Zarko earlier, works perfectly fine in both cases.
    – leandriis
    Jan 9, 2020 at 20:34
  • it is indeed solved using \addlinespace
    – Smilia
    Jan 9, 2020 at 21:02

2 Answers 2

8

Let me convert my comment to an answer:

Problem of adding space after row in tabularx table is explained in David Carlisle answer. From it as solution for your problem is terminate table row with

 ... \\ \noalign{\vspace{4pt}}

or use \addlinespace from the package booktabs as I suggested in the comment. Use of both ways are presented in the following MWE:

\documentclass{article}
\usepackage{booktabs, tabularx}

\begin{document}
    \begin{tabularx}{\textwidth}{lX}
    row1 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        \\ \noalign{\vspace{4pt}}
    row2 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        \\
    \addlinespace[4pt]
    row3 & Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{tabularx}
\end{document}

As you can see, between all rows is vertical space of 4pt. The first is determined as suggested in the @David answer (see link), the second as I suggest in my comment.

Note: default vertical space which is added by command \addlinespace is .5em. If you like to have different vertical distance, add it as option to command, for example as is done in MWE above

enter image description here

2

Unnecessary use of tabularx (and the dummy text):

mwe

\documentclass{article}
\usepackage{lipsum} 
\settowidth{\labelwidth}{row X}
\setlength{\labelsep}{2\tabcolsep}
\setlength{\leftmargini}{\dimexpr\labelwidth+\labelsep\relax}
\begin{document}
\lipsum[1][1-7]
\begin{itemize}
% \setlength{\itemsep}{11ex} % set as needed
\item[row 1] \lipsum[1][1-4]
\item[row 2] \lipsum[2][1-4]
\item[row 3] \lipsum[3][1-4]
\end{itemize}
\lipsum[5]
\end{document}

Note: using tabularx, one dirtier trick, but easier to type than \\\noalign{\vspace{4pt}} is \\\\[-8pt] instead of \\[4pt] (however, not a good idea using \rowcolors, obviously).

You must log in to answer this question.

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