[Tex/LaTex] vspace before itemize in a Table cell, tabular vs longtable

longtablespacingtables

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…

Best Answer

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.