我尝试为一种新的项目化方式定义一个新环境,但是当我使用新环境(名为 itemize-compact)时,我收到错误“缺少项目”(表格内)或“缺少列表环境”。
(仅供参考:最后我想使用 newenvironment 来定义一个列表,其中项目之间、上方、下方和左侧的空间较少,使用 labelsep 和 parsep 等函数,以便在表格中使用。)
下面是一个 MWE,它既在表格中使用了新定义的 itemize,也在一般文本中使用了新定义的 itemize。我附上了一张结果图片。
提前谢谢您!
\documentclass{book}
\usepackage{array,enumitem}
\newenvironment{itemize-compact}%
{\begin{itemize}
%no alternative properties included yet, because this already gives the errors stated below
\end{itemize}}
\begin{document}
\begin{tabular}{|m{5cm}|m{10cm}|}
\hline
Text &
\begin{itemize}
\item itemize within tabular works fine
\end{itemize}
\\
\hline
\end{tabular}
\begin{tabular}{|m{5cm}|m{10cm}|}
\hline
Text &
\begin{itemize-compact}
\item the newly defined environment `itemize-compact' within tabular gives the error: *there's something wrong, perhaps a missing item*
\end{itemize-compact}
\\
\hline
\end{tabular}
\begin{itemize}
\item itemize works fine
\end{itemize}
\begin{itemize-compact}
\item the newly defined environment `itemize-compact' gives the error: *lonely item, perhaps a missing list environment*
\end{itemize-compact}
\end{document}