2

From egreg answer to this question, I have learned to redirect \@minipagetrue into table cells to get rid of the extra space above enumerate-environments (and itemize and description). However, if I try this trick in a longtable, it will not work. I can set the enumerate in a \parbox, but then I do not need the redirection. Here is an MWE (taken from the referred answer and modified).

Is this a feature, a bug or is it me misunderstanding (i.e. user error)?

enter image description here

\documentclass[fontsize=11pt]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{array, longtable}
\usepackage{enumitem}
\makeatletter
\newcolumntype{P}[1]{>{\@minipagetrue}p{#1}}
\makeatother

\begin{document}

\noindent\begin{tabular}{|P{0.2 \linewidth}|P{0.2 \linewidth}|}
\hline
lipsum & 
\begin{itemize}[nosep, leftmargin=*]
\item A
\item B
\end{itemize}
lipsum \\
\hline
lipsum & lipsum\\
\hline
\end{tabular}

\bigskip

\begin{longtable}[l]{|P{0.2 \linewidth}|P{0.2 \linewidth}|}
\hline
lipsum & 
\begin{itemize}[nosep, leftmargin=*]
\item A
\item B
\end{itemize}
lipsum \\
\hline
lipsum & 
\parbox[t]{\linewidth}{\begin{itemize}[nosep, leftmargin=*]
\item A
\item B
\end{itemize}}
lipsum \\
\hline
lipsum & lipsum\\
\hline
\end{longtable}

\end{document}
Sveinung
  • 20,355
  • 1
    The same problem is with xltabular (which also use longtable) at p or X column type. – Zarko Jan 07 '20 at 17:50
  • @Zarko Thank you. I changed the heading and tagging to include xltabular. – Sveinung Jan 07 '20 at 18:18
  • 1
    It seems that this is bug in longtable. Meanwhile i tested \newcolumntype{M}[1]{>{\minipage{\hsize}\raggedright\arraybackslash}p{#1}<{\endminipage}}. It reduce vertical space before itemize for about 1/3 \baselineskip . Interestingly ... – Zarko Jan 07 '20 at 19:17
  • @Zarko It is the same effect you get when you redirect @minipagetrue into the column. Since minipage need a width, this is a hassle in LaTeX standard tabulars which do not reset \hsize. In longtable, it is a good alternative to define a special purpose column, since \hsize contains the column width. You should set the [t] option in the minipage, to have same vertical alignment as the content of other cells in the row. – Sveinung Jan 07 '20 at 21:43
  • @Zarko Since your comments is the only answer I get, I suggest that you you write an answer,indicating the your comment is an an alternative solution. – Sveinung Jan 18 '20 at 21:04

1 Answers1

1

I found that the problem noted in your question partly can be solved with following definition of column type:

\newcolumntype{M}[1]{>{\minipage{\hsize}\arraybackslash}p{#1}<{\endminipage}}

Interestingly is, that above column type definition doesn't work if you remove \arraybackslash from it. For test try the following MWE:

\documentclass[fontsize=11pt]{article}
\usepackage{array, longtable}
\usepackage{enumitem}
\newcolumntype{M}[1]{>{\minipage{\hsize}\arraybackslash}p{#1}<{\endminipage}}
\makeatletter
\newcolumntype{P}[1]{>{\@minipagetrue}p{#1}} %this not work as expected :-(
\makeatother

\begin{document}

\begingroup
    \centering
    \setlist[itemize]{nosep, leftmargin=*}
\begin{tabular}{|P{0.2\linewidth}|P{0.2\linewidth}|}
    \hline
lipsum  &   \begin{itemize}
        \item A
        \item B
            \end{itemize}
            lipsum \\
    \hline
lipsum  &   lipsum\\
    \hline
\end{tabular}

\medskip
\begin{longtable}{|P{0.2\linewidth}|P{0.2\linewidth}|}
    \hline
lipsum  &   \begin{itemize}
        \item A
        \item B
            \end{itemize}
            lipsum \\
    \hline
lipsum  &   lipsum\\
    \hline
    \end{longtable}

\medskip
\begin{longtable}{|M{0.2\linewidth}|M{0.2\linewidth}|}
    \hline
lipsum  &   \begin{itemize}
        \item A
        \item B
            \end{itemize}
            lipsum \\
    \hline
lipsum  &   lipsum\\
    \hline
    \end{longtable}
\endgroup
\end{document}

which gives the following result:

enter image description here

Sveinung
  • 20,355
Zarko
  • 296,517