# vspace before itemize in a Table cell, tabular vs longtable

In the following MWE, one sees the difference between tabular and longtable, with respect to the vertical space before an itemize, inside a cell :

\documentclass[12pt]{article}
\usepackage{longtable,enumitem}
\begin{document}
\begin{longtable}{| p{3cm} |p{6cm}|}
\hline%
text &
\begin{itemize}[topsep=0ex,partopsep=0ex]
\item Produkt und Quotient
\item Produkt und Quotient
\end{itemize}
\\ \hline
\end{longtable}

\begin{tabular}{| p{3cm} |p{6cm}|}
\hline%
text &
\begin{itemize}[topsep=0ex,partopsep=0ex]
\item Produkt und Quotient
\item Produkt und Quotient
\end{itemize}
\\ \hline
\end{tabular}

\end{document}


What i would like, is to have in longtable the same vspace as in tabular. By the way, i set both topsep and partopsep to 0, just because i am ignorant, and i don't really know which one i should use...

Oh! Sorry I think this is an unreported bug in longtable.

Longtable inserts a strut to keep a minimal separation between the text and any \hline or the previous row.

It does this with the following code

\def\LT@startpbox#1{%
\bgroup
\let\@footnotetext\LT@p@ftntext
\setlength\hsize{#1}%
\@arrayparboxrestore
\vrule \@height \ht\@arstrutbox \@width \z@}


If you look at the equivalent code in the array package, you find

\def\@startpbox#1{\bgroup
%    \end{macrocode}
%    The argument is the width of the box. This information has to be
%    assigned to =\hsize=.
%    Then we assain default values to several parameters used in a
%    \textsf{parbox}.
% \changes{v2.3k}{1998/05/12}{Use \cs{setlength} to set \cs{hsize},
%      so that the calc package can be applied here (pr/2793)}
%    \begin{macrocode}
\setlength\hsize{#1}\@arrayparboxrestore
%    \end{macrocode}
%    Our main problem is to obtain the same distance between succeeding
%    lines of the \textsf{parbox}.
%    We have to remember that the distance between two \textsf{parboxes}
%    should be defined by =\@arstrut=. That means that it can be
%    greater than the distance in a \textsf{parbox}.
%    Therefore it is not enough to set a =\@arstrut= at the
%    beginning and at the end of the \textsf{parbox}. This would
%    dimension the distance
%    between first and second line and the distance between the two
%    last lines of the \textsf{parbox} wrongly.
%    To prevent this we set an invisible rule of height
%    =\@arstrutbox=
%    at the beginning of the \textsf{parbox}. This has no effect on the
%    depth of the first line. At the end of the \textsf{parbox} we set
%    analogously another invisible rule which only affects the depth
%    of the last line. It is necessary to wait inserting this strut
%    until the paragraph actually starts to allow for things like
%    =\parindent= changes via =>{...}=.
% \changes{v2.1c}{1992/12/14}{Use everypar to insert strut}
%    \begin{macrocode}
\everypar{%
\vrule \@height \ht\@arstrutbox \@width \z@
\everypar{}}%
}
%    \end{macrocode}
% \end{macro}


The important bit being the last few lines which delay adding the strut by using \everypar.

It seems to me the same fix should have been applied to longtable so only 20 years too late I suggest

\def\LT@startpbox#1{%
\bgroup
\color@begingroup% Omit line if package date older than 2014/10/28
\let\@footnotetext\LT@p@ftntext
\setlength\hsize{#1}%
\@arrayparboxrestore
\everypar{%
\vrule \@height \ht\@arstrutbox \@width \z@
\everypar{}}%
%    \vrule \@height \ht\@arstrutbox \@width \z@
}


which then makes both your tables have the same vertical spacing.

If you do this could you change

\ProvidesPackage{longtable}
[2004/02/01 v4.11 Multi-page Table package (DPC)]


to

\ProvidesPackage{longtable}
[2004/02/01 v4.11 Multi-page Table package (DPC) + strut fix]


I suspect after all this time I can't change longtables default spacing, however I should add an option to fix it.

• I'm delighted to have found a 20-years-old bug ... and to get the fix by the original developer ! Thanks :) – nicolas roy Mar 5 '12 at 7:28
• Note that there has been a change of definition from probably package date 2004/02/01 to 2014/10/28 (unfortunately, both called v4.11). Without the correction, you get the following error when using \makeatletter and xcolor: "Missing } inserted". The included line above fixes the problem, i.e. adding "\color@begingroup". – Patrick Häcker Aug 16 '19 at 10:09
• @PatrickHäcker thanks for the fix, the change is newer actually, the matching chnage in array.sty is % \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)}, longtable unfortunately went out with [2014/10/28 v4.11 Multi-page Table package (DPC)+ FMi change] (note the FMI comment) it is fixed in sources so will have a "real" new version date at the next release. – David Carlisle Aug 16 '19 at 10:18
• @DavidCarlisle thanks for the additional information, that explains why the problem occured only recently on my system. IMHO it would still make sense to add an option to longtable to apply the spacing fix without the need to fix all the custom user macros with code copied from a web page. Anything planned like that? – Patrick Häcker Aug 16 '19 at 18:23
• @PatrickHäcker perhaps although there are a stack of competing change requests on longtable, so not sure when they will get resolved, htmlpreview.github.io/?https://raw.githubusercontent.com/… – David Carlisle Aug 16 '19 at 18:30

Why don't you use a dedicated column type for this (originally posted by Donald Arseneau on c.t.t.), otherwise spacing is always a problem.

\documentclass[12pt]{article}
\usepackage{longtable,array,enumitem}
\makeatletter
%----  Enumerated columns
\newcolumntype{e}[1]{%
>{\minipage[t]{\linewidth}\let\\\tabularnewline
\enumerate
\setlength{\itemsep}{-\parsep}}%
p{#1}%
<{\@finalstrut\@arstrutbox\endenumerate\endminipage}}

%---- Itemized columns
\newcolumntype{i}[1]{%
>{\minipage[t]{\linewidth}\let\\\tabularnewline
\itemize
\setlength{\itemsep}{-\parsep}}%
p{#1}%
<{\@finalstrut\@arstrutbox\enditemize\endminipage}}
\makeatother

\begin{document}
\begin{longtable}{| p{3cm} |p{6cm}|}
\hline%
text &
\begin{itemize}[topsep=0ex,partopsep=0ex]
\item Produkt und Quotient
\item Produkt und Quotient
\end{itemize}
\\ \hline
text &
\multicolumn{1}{i{6cm}|}{
\item Produkt und Quotient
\item Produkt und Quotient
}\\ \hline
\end{longtable}

\begin{center}
\begin{tabular}{| p{3cm} |p{6cm}|}
\hline%
text &
\begin{itemize}[topsep=0ex,partopsep=0ex]
\item Produkt und Quotient
\item Produkt und Quotient
\end{itemize}
\\ \hline
text &
\multicolumn{1}{i{6cm}|}{
\item Produkt und Quotient
\item Produkt und Quotient
}\\ \hline
\end{tabular}
\end{center}

\end{document}
`