在回忆录中的长表中逐项列出环境后删除多余的空间

在回忆录中的长表中逐项列出环境后删除多余的空间

我有一个宏,在其中创建 itemize 环境。问题是,在 longtable 中使用时,itemize 环境后面有多余的空格。如何删除空格?

\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}

在此处输入图片描述

添加

该解决方案-\baselineskip:适用于文章类,但不适用于回忆录类。

答案1

p表中的列条目基本上以

\unskip \strut \par \egroup \hfil

因此,在列表之后,您会得到一个\strut出现在新行上的添加项。您可以使用以下命令进行备份-\baselineskip

示例输出

\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}

p普通表格中的单元格同样如此。

添加memoir课堂上,的定义\@endpbox有点不同,你需要写

 \vspace*{-\baselineskip}\leavevmode

而不只是命令\vspace*

答案2

在此处输入图片描述

\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}

答案3

或者您可以使用minipage

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

完整代码:

\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}

在此处输入图片描述

相关内容