# Longtable and itemize - remove vertical space

My table currently looks as follows:

This is the code:

\begin{longtable}{|P{7cm}|P{7cm}|}
\caption{Test table} \\
\hline

\rowcolor{black} \textcolor{white}{\textbf{Column 1}} & \textcolor{white}{\textbf{Column 2}}  \\ \hline

First Row & \vspace{-\baselineskip}
\begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
\item Vans (last 2 months)
\item Cars
\item Trucks
\item Planes
\end{itemize} \\ \hline

Second Row & \vspace{-\baselineskip}
\begin{itemize}[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
\item Apple (last 2 months)
\item Banana
\end{itemize} \\ \hline

\end{longtable}


How can I remove the vertical space in Column 2 before and after the list?

Thanks.

• Take a look here – Skillmon May 15 '18 at 9:16
• What is the P column type? – Bernard May 15 '18 at 10:10

Not knowing what is the P column type, I replaced it with p. Note your table a slightly too wide for the default layout of geometry.

\documentclass[a4paper, 10pt]{article}
\usepackage[ showframe]{geometry}
\usepackage{longtable}
\usepackage{enumitem}
\usepackage[table]{xcolor}

\begin{document}

\begingroup
\setlist[itemize]{label={--},nosep, leftmargin=*, before=\vspace*{-\baselineskip}, after=\vspace*{-0.9\baselineskip}}
\setlength{\extrarowheight}{3pt}
\begin{longtable}{|p{7cm}| p{7cm}|}
\caption{Test table} \\
\hline
\rowcolor{black} \textcolor{white}{\textbf{Column 1}} & \textcolor{white}{\textbf{Column 2}} \\ \hline
\hline
\rowcolor{black} \textcolor{white}{\textbf{Column 1}} & \textcolor{white}{\textbf{Column 2}} \\ \hline
First Row &
\begin{itemize}
\item Vans (last 2 months)
\item Cars
\item Trucks
\item Planes
\end{itemize}
\\
\hline
Second Row & %\vspace{-\baselineskip}
\begin{itemize}%[label={--},noitemsep,leftmargin=*,topsep=0pt,partopsep=0pt]
\item Apple (last 2 months)
\item Banana
\end{itemize} \\
\hline
\end{longtable}
\endgroup

\end{document}


• i think that definition of \newcommand*{\compress}{\@minipagetrue} is superfluous. i don't see that it is used in table :-). also you can show how to define columns widths that table is not wider than text width. – Zarko May 15 '18 at 10:51
• @Zark: You're right. It was a first test (ifor a shorter code), but it didn't work in this case, and I forgot to remove it. Thanks for pointing it! – Bernard May 15 '18 at 11:07

Here's a solution that produces tight spacing in the second column by placing each cell in a minipage.

Note that I also recommend (a) not using any vertical bars and (b) using fewer, but well-spaced, horizontal bars.

\documentclass{article}
\usepackage{geometry} % set page dimension parameters suitably
\usepackage{enumitem}
\usepackage{longtable}
\usepackage[table]{xcolor}
\newlist{myitemize}{itemize}{1}
\setlist[myitemize]{label={--},nosep,leftmargin=*}
\usepackage{array,ragged2e,booktabs}
\setlength\extrarowheight{2pt}

\begin{document}

\begin{longtable}{p{7cm}p{7cm}}
%% set up headers and footers
\caption{Test table} \label{tab:test} \\
\rowcolor{black}
\textcolor{white}{\textbf{Column 1}} &
\textcolor{white}{\textbf{Column 2}}

\multicolumn{2}{l}{(Table \ref{tab:test}, cont'd)}\\
\rowcolor{black}
\textcolor{white}{\textbf{Column 1}} &
\textcolor{white}{\textbf{Column 2}}

\midrule
\multicolumn{2}{r}{(continued on next page)}\\
\endfoot

\bottomrule
\endlastfoot

%% body of table
First Row &
\begin{minipage}[t]{7cm} % same width as overall col. width
\RaggedRight % just an educated guess...
\begin{myitemize}
\item Vans (last 2 months)
\item Cars
\item Trucks
\item Planes
\end{myitemize}
\end{minipage}\\
Second Row &
\begin{minipage}[t]{7cm}
\RaggedRight
\begin{myitemize}
\item Apple (last 2 months)
\item Banana \strut % "\strut": a typographic strut
\end{myitemize}
\end{minipage}\\

\end{longtable}
\end{document}

• I'd put a \strut after the Banana, for better spacing. – Skillmon May 15 '18 at 13:23
• @Skillmon - Great suggestion! Implemented. – Mico May 15 '18 at 14:04