我有一个包含枚举环境的表。问题是,在 itemize 环境中的第一个项目之前有一个空行。我该如何删除它?
\documentclass{article}
\usepackage{booktabs}
\usepackage{enumitem}
\newcommand{\fu}[1]{%
%\tightlist%
\begin{itemize}[nosep]%
#1%
\end{itemize}%
\vspace{-\baselineskip}\mbox{}}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{l|p{0.6\textwidth}}
\toprule
\textbf{SB Solution Component} & \textbf{BB Data Satisfied}
\\\midrule
\textbf{Registration Module} & \fu{
\item Capability List
\item Representation List}
\\\midrule
\textbf{Sensing Data Module} & \fu{
\item Ready Signal
}
\\\midrule
\textbf{Contexts Module} & \fu{
\item Control List
\item Contexts
}
\\
\bottomrule
\end{tabular}
\caption{BB Data Satisfied for SB Solution Component}
\label{tab:data}
\end{table}
\end{document}
答案1
为此使用专用的列类型(最初由 Donald Arseneau 在 ctt 上发布)
\documentclass{article}
\usepackage{array,booktabs}
%---- Itemized columns
\makeatletter
\newcolumntype{i}[1]{%
>{\minipage[t]{\linewidth}\let\\\tabularnewline
\itemize
\addtolength{\rightskip}{0pt plus 50pt}% for raggedright
\setlength{\itemsep}{-\parsep}}%
p{#1}%
<{\@finalstrut\@arstrutbox\enditemize\endminipage}}
\makeatother
\begin{document}
\begin{tabular}{l|i{0.6\textwidth}}
\toprule
\textbf{SB Solution Component} & \multicolumn{1}{p{0.6\textwidth}}{\textbf{BB Data Satisfied}} \\
\midrule
\textbf{Registration Module} & \item Capability List
\item Representation List \\
\midrule
\textbf{Sensing Data Module} & \item Ready Signal \\
\midrule
\textbf{Contexts Module} & \item Control List
\item Contexts \\
\bottomrule
\end{tabular}
\end{document}
答案2
这似乎与段落框在环境列中的工作方式有关tabular
。我不明白这是错误还是功能;对此有更深入理解的人tabular
应该会看到它。
对于比@Adam 的解决方案更简单的解决方案,我建议您使用minipage
而不是p
中的列tabular
。定义:
\newcommand{\fu}[1]{%
\begin{minipage}[t]{0.6\textwidth}%
\begin{itemize}[nosep]%
#1%
\end{itemize}%
\end{minipage}}
然后,将表格更改为:
\begin{tabular}{l|l}
(我不相信你[htbp]
在那里是必要的。)
答案3
\vspace{...}
就像我在评论中提到的那样,我不完全确定发生了什么,但是在你的内部使用一种有点黑客的解决方案\newcommand
。
\documentclass{article}
\usepackage{booktabs}
\usepackage{enumitem}
\newcommand{\fu}[1]{%
%\tightlist%
\vspace{-9pt}
\begin{itemize}[nosep,topsep=0pt]%
#1%
\end{itemize}%
\vspace{-\baselineskip}\mbox{}}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}[htbp]{l|p{0.6\textwidth}}
\toprule
\textbf{SB Solution Component} & \textbf{BB Data Satisfied}
\\\midrule
\textbf{Registration Module} & \fu{
\item Capability List
\item Representation List}
\\\midrule
\textbf{Sensing Data Module} & \fu{
\item Ready Signal
}
\\\midrule
\textbf{Contexts Module} & \fu{
\item Control List
\item Contexts
}
\\
\bottomrule
\end{tabular}
\caption{BB Data Satisfied for SB Solution Component}
\label{tab:data}
\end{table}
\end{document}