如何控制表格中插入 itemize(listing) 环境前后的空格?

如何控制表格中插入 itemize(listing) 环境前后的空格?

我有一个宏,用于在 longtable 中插入 itemize 环境。问题是 itemize 环境的顶部和底部之间有很大空间。

我怎样才能控制空间?

在此处输入图片描述

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

\newcommand{\heu}[1]{%
\textit{BB Heuristic:} #1%
}%

\newcommand{\whypri}[2]{%
\begin{itemize} %
\item \textit{Why}: #1%
\item \textit{Priority Justification}: #2%
\end{itemize}%
}

\begin{document}

\begin{longtable}{c|p{0.4\textwidth}|p{0.5\textwidth}}
\caption[Derivation Plan]{Derivation Plan} \label{d_plan} \\
   \toprule
\textbf{1} & \multicolumn{2}{l}{\textbf{Goal: Extensibility}} \\\midrule
1.1 
& \heu{Reduce Data/Event Dependency}
&  \whypri{Extensible components should be working as a standalone that has minimum
dependency on other components. The more dependencies, the more complexity
Occurs To prevent extensible structure.}{Less complexity in extension introduced
by reducing dependency.}
\\\midrule
%\st{BB Heuristic: }
\bottomrule
\end{longtable}

\end{document}

答案1

您可以使用minipage

\newcommand{\whypri}[2]{%
\begin{minipage}[t]{\linewidth}
\begin{itemize} %
\item \textit{Why}: #1%
\item \textit{Priority Justification}: #2%
\end{itemize}%
\end{minipage}%
}

此外,我还会使用enumitem和应用leftmargin=*。完整代码如下:

\documentclass[draft]{article}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{enumitem}

\newcommand{\heu}[1]{%
\textit{BB Heuristic:} #1%
}%

\newcommand{\whypri}[2]{%
\begin{minipage}[t]{\linewidth}
\begin{itemize}[leftmargin=*] %
\item \textit{Why}: #1%
\item \textit{Priority Justification}: #2%
\end{itemize}%
\end{minipage}%
}

\begin{document}

\begin{longtable}{c|p{0.4\textwidth}|p{0.5\textwidth}}
\caption[Derivation Plan]{Derivation Plan} \label{d_plan} \\
   \toprule
\textbf{1} & \multicolumn{2}{l}{\textbf{Goal: Extensibility}} \\\midrule
1.1
&\raggedright \heu{Reduce Data/Event Dependency}
&  \whypri{Extensible components should be working as a standalone that has minimum
dependency on other components. The more dependencies, the more complexity
Occurs To prevent extensible structure.}{Less complexity in extension introduced
by reducing dependency.}
\\\midrule
%\st{BB Heuristic: }
\bottomrule
\end{longtable}

\end{document}

在此处输入图片描述

而且我还会删除垂直线并将其用于l第一列。

\begin{longtable}{lp{0.4\textwidth}p{0.5\textwidth}}

在此处输入图片描述

相关内容