5

The code is the following:

\documentclass[a4paper,10pt]{article}

\usepackage{longtable}
\usepackage{tabularx}

\newcolumntype{L}{>{\raggedleft}p{0.1\textwidth}}
\newcolumntype{R}{p{0.80\textwidth}}

\begin{document}
\begin{longtable}{L!{---}R}
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\\[10pt]
12 & asdf asdf asdf asdf asdf.\\[10pt]
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\\[10pt]
\end{longtable}
\end{document}

and the output is enter image description here that is, in each row, the vertical space 10pt is considered from the first line and not from the last line. If, for instance, in the first row you put 30pt instead of 10pt, then a vertical space appears between the first and the second row. I think this problem appeared in an updating of some packages of MikTeX.

Does anyone know of any solution to this problem?

Thanks

3

2 ways:

Employ \extrarowheight from array package

\documentclass[a4paper,10pt]{article}

\usepackage{longtable,array}
\usepackage{tabularx}
\newcolumntype{L}{>{\raggedleft}p{0.1\textwidth}}
\newcolumntype{R}{p{0.80\textwidth}}
\setlength\extrarowheight{10pt}
\begin{document}
\begin{longtable}{L!{---}R}
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\\
12 & asdf asdf asdf asdf asdf.\\
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\\
\end{longtable}
\end{document}

Build a strut

Here, I create \mystrut, which you can just add to the end of each 3rd-column entry, in lieu of \\[10pt]. One could have just chosen a simple fixed dimension as in \newcommand\mystrut{\rule[-10pt]{0pt}{0pt}}, but I instead did a dimensional expression to be the equivalent of \\[10pt].

\documentclass[a4paper,10pt]{article}

\usepackage{longtable}
\usepackage{tabularx}
\newcommand\mystrut{\rule[\dimexpr-\dp\strutbox-10pt\relax]{0pt}{0pt}}
\newcolumntype{L}{>{\raggedleft}p{0.1\textwidth}}
\newcolumntype{R}{p{0.80\textwidth}}

\begin{document}
\begin{longtable}{L!{---}R}
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf 
  asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf 
  asdf asdf asdf asdf asdf.\mystrut\\
12 & asdf asdf asdf asdf asdf.\mystrut\\
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\mystrut\\
\end{longtable}
\end{document}

Either approach gives the following output (plus/minus some leading space at the beginning of the table)

enter image description here

2

You can use \addlinespace from booktabs:

\documentclass[a4paper,10pt]{article}

\usepackage{longtable}
\usepackage{tabularx}

\newcolumntype{L}{>{\raggedleft}p{0.1\textwidth}}
\newcolumntype{R}{p{0.80\textwidth}}

\usepackage{booktabs}
\setlength{\defaultaddspace}{10pt}

\begin{document}

\begin{longtable}{L!{---}R}
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\\
\addlinespace
12 & asdf asdf asdf asdf asdf.\\
\addlinespace
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.
\end{longtable}

\end{document} 

enter image description here

1

The \\[<dimen> command in a table tells LaTeX that the current row extends at least <dimen> below the baseline, in addition to the depth of a strut. Since your row extends much deeper than 10pt, the [10pt] argument adds nothing.

The \addlinespace command provided by booktabs, which could simply called

\addlinespace[10pt]

instead of globally changing \defaultaddspace is good. Without packages, you can do

\noalign{\vspace{10pt}}

between rows.

I suggest using the relatively new w column specifier instead of >{\raggedleft}p{0.1\textwidth}, for a column where line breaks are not needed. It requires \usepackage{array}, which is automatically called by tabularx. In the code below I load it explicitly. It's needed anyway for \newcolumntype.

\documentclass[a4paper,10pt]{article}

\usepackage{longtable}
\usepackage{array}

\newcolumntype{L}{w{r}{0.1\textwidth}}
\newcolumntype{R}{p{0.80\textwidth}}

\begin{document}

\begin{longtable}{L!{---}R}
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf 
     asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf
     asdf asdf asdf asdf asdf asdf asdf.\\
\noalign{\vspace{10pt}}
12 & asdf asdf asdf asdf asdf.\\
\noalign{\vspace{10pt}}
12 & asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf.\\
\end{longtable}

\end{document}

enter image description here

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.