Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a macro that creates itemize environment in it. The issue is that I have extra space after the itemize environment when used in longtable. How to remove the space?

\documentclass{memoir}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{booktabs}

\newcommand{\fuda}[2]{%
Functions:%
\begin{itemize}[nosep]
#1%
\end{itemize}
Data:%
\begin{itemize}[nosep]
#2%
\end{itemize}
}
\begin{document}
\begin{longtable}{p{0.3\textwidth}|p{0.7\textwidth}}
\caption[List of components]{List of functions and data allocated to each component} \label{d_plan} \\
\toprule
\textbf{Components} & \textbf{Functions and Data} \\\midrule
\textbf{Registration} & \fuda{
\item Register capabilities of the device
\item Unregister capabilities of the device
\item Register context representation 
}{
\item  Interface List 
\item Capability List
\item  Protocol List
\item Representation List}
\\\bottomrule
\end{longtable}
\end{document}

enter image description here

ADDED

The solution that uses -\baselineskip: works with article class, but not with memoir class.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

A p column entry in a table ends with essentially

\unskip \strut \par \egroup \hfil

so after your list you get a \strut added which appears on a newline. You can back-up with -\baselineskip:

Sample output

\documentclass{article}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{booktabs}

\newcommand{\fuda}[2]{%
Functions:%
\begin{itemize}[nosep]
#1%
\end{itemize}
Data:%
\begin{itemize}[nosep]
#2%
\end{itemize}}

\begin{document}

\begin{longtable}{p{0.25\textwidth}|p{0.7\textwidth}}
\caption[List of components]{List of functions and data allocated to each component} \label{d_plan} \\
\toprule
\textbf{Components} & \textbf{Functions and Data} \\\midrule
\textbf{Registration} &\fuda{\item Register capabilities of the device
\item Unregister capabilities of the device
\item Register context representation 
}{\item  Interface List 
\item Capability List
\item  Protocol List
\item Representation List}\vspace*{-\baselineskip}
\\\bottomrule
\end{longtable}

\end{document}

The same applies to p cells in ordinary tables.

Added in the memori class the definition of \@endpbox is a little difference and you will need to write

 \vspace*{-\baselineskip}\leavevmode

instead of just the \vspace* command.

share|improve this answer
    
This solution works with article, but with memoir it doesn't work. –  prosseek Oct 31 '13 at 18:27

enter image description here

\documentclass{memoir}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{booktabs}

\newcommand{\fuda}[2]{%
Functions:%
\begin{itemize}[nosep]
#1%
\end{itemize}
Data:%
\begin{itemize}[nosep]
#2%
\end{itemize}}

\begin{document}

\begin{longtable}{p{0.25\textwidth}|p{0.7\textwidth}}
\caption[List of components]{List of functions and data allocated to each component} \label{d_plan} \\
\toprule
\textbf{Components} & \textbf{Functions and Data} \\\midrule
\textbf{Registration} &\fuda{\item Register capabilities of the device
\item Unregister capabilities of the device
\item Register context representation 
}{\item  Interface List 
\item Capability List
\item  Protocol List
\item Representation List}
\vspace{-\baselineskip}\mbox{}
\\\bottomrule
\end{longtable}

\end{document}
share|improve this answer

Or you can use a minipage.

\newcommand{\fuda}[2]{%
\begin{minipage}[t]{\linewidth}
Functions:%
\begin{itemize}[nosep]
#1%
\end{itemize}
Data:%
\begin{itemize}[nosep]
#2%
\end{itemize}
\end{minipage}}

Full code:

\documentclass{memoir}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{booktabs}

\newcommand{\fuda}[2]{%
\begin{minipage}[t]{\linewidth}
Functions:%
\begin{itemize}[nosep]
#1%
\end{itemize}
Data:%
\begin{itemize}[nosep]
#2%
\end{itemize}
\end{minipage}}

\begin{document}

\begin{longtable}{p{0.25\textwidth}|p{0.7\textwidth}}
\caption[List of components]{List of functions and data allocated to each component} \label{d_plan} \\
\toprule
\textbf{Components} & \textbf{Functions and Data} \\\midrule
\textbf{Registration} &\fuda{\item Register capabilities of the device
\item Unregister capabilities of the device
\item Register context representation
}{\item  Interface List
\item Capability List
\item  Protocol List
\item Representation List}
\\\bottomrule
\end{longtable}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.