enumitem
当我编译包含和包的 LaTeX 文档时遇到错误paralist
。这是我的 MWE 代码:
\documentclass{article}
\usepackage{enumitem}
\usepackage{paralist}
\begin{document}
\begin{tabular}{lp{10cm}}
\scshape Assume: & \begin{compactenum}
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{enum}
\\
\scshape Prove: & False
\end{tabular}
\begin{enumerate}[label=\bfseries Case \arabic*:,leftmargin=*]
\item
It rains today.
\item
It does not rain today.
\end{enumerate}
\end{document}
我该如何修复这个错误?有没有办法定义我自己的compactenum
使用,enumitem
这样我就不需要包含paralist
包了?
答案1
你不需要使用包裹paralist
完全没有。只需使用来自包裹enumitem
——需要将inline
选项添加到enumitem
包中:
如果您不希望表格中的枚举值单独占一行,您可以调整用于垂直间距的所有参数。下面是我曾经[topsep=0pt,partopsep=0pt,itemsep=0pt, parsep=0pt]
实现的:
参考:
编译错误
您可以通过以下方式修复原始编译错误:
- 加载
paralist
前enumitem
。 - 替换
\end{cenum}
为\end{compactenum}
代码:inline
\documentclass{article}
\usepackage[inline]{enumitem}
%\usepackage{paralist}
\begin{document}
\begin{tabular}{lp{10cm}}
\scshape Assume: & \begin{enumerate*}
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{enumerate*}
\\
\scshape Prove: & False
\end{tabular}
\begin{enumerate}[label=\bfseries Case \arabic*:,leftmargin=*]
\item
It rains today.
\item
It does not rain today.
\end{enumerate}
\end{document}
代码:Tight Spacing
:
\documentclass{article}
\usepackage{enumitem}
%\usepackage{paralist}
\begin{document}
\begin{tabular}{lp{10cm}}
\scshape Assume: & \begin{enumerate}[topsep=0pt,partopsep=0pt,itemsep=0pt, parsep=0pt]
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{enumerate}
\\
\scshape Prove: & False
\end{tabular}
\begin{enumerate}[label=\bfseries Case \arabic*:,leftmargin=*]
\item
It rains today.
\item
It does not rain today.
\end{enumerate}
\end{document}
代码:Fix Compilation Error
\documentclass{article}
\usepackage{paralist}
\usepackage{enumitem}
\begin{document}
\begin{tabular}{lp{10cm}}
\scshape Assume: & \begin{compactenum}
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{compactenum}
\\
\scshape Prove: & False
\end{tabular}
\begin{enumerate}[label={\bfseries Case \arabic*:},leftmargin=*]
\item
It rains today.
\item
It does not rain today.
\end{enumerate}
\end{document}
答案2
如果我反转加载和的顺序paralist
,enumitem
并更改\end{enum}
为,您的示例可以很好地编译\end{compactenum}
。但我不知道这是否符合您的要求。注意:当包发生冲突时,可以尝试更改加载顺序。
另一方面,compactenum
可以仅使用包的功能来定义环境enumerate
,因此paralist
可能没有必要:
\documentclass{article}
\usepackage{enumitem}
\newenvironment{compactenum}{%
\enumerate[topsep=0pt,partopsep=0pt,parsep=0pt,itemsep=0pt]%
}{\endenumerate}
\begin{document}
\begin{tabular}{lp{10cm}}
\scshape Assume: &
\begin{compactenum}
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{compactenum}
\\
\scshape Prove: & False
\end{tabular}
\begin{enumerate}[label=\bfseries Case \arabic*:,leftmargin=*]
\item It rains today.
\item It does not rain today.
\end{enumerate}
\end{document}
有人可能想给命令0pt
中设置的四个值赋予一点可伸缩性\enumerate
。也就是说,0pt
用0pt plus 1pt
或替换\parskip
。
答案3
这是基于 Dan 和 Peter Grill 的答案。只是为了展示如何使用 来enumitem
创建具有所需属性的新列表。我调用它是为了在同一文档中mycompactenum
包含 进行比较,但显然如果您想这样做,您可以使用。此解决方案还使用的选项来消除垂直间距。这相当于将、 和全部设置为零。compactenum
paralist
compactenum
enumitem
nosep
partopsep
topsep
itemsep
parsep
\documentclass{article}
\usepackage{paralist}
\usepackage{enumitem}
\newlist{mycompactenum}{enumerate}{1}
\setlist[mycompactenum,1]{nosep,label=\arabic*.}
\begin{document}
\marginpar{\texttt{paralist}}
\begin{tabular}{lp{10cm}}
\scshape Assume: &
\begin{compactenum}
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{compactenum}
\\
\scshape Prove: & False
\end{tabular}\bigskip
\marginpar{\texttt{enumitem}}
\begin{tabular}{lp{10cm}}
\scshape Assume: &
\begin{mycompactenum}
\item $(p_1, p_2)$ is an optimal price sequence
\item $p_2 > p_1 > 0$
\end{mycompactenum}
\\
\scshape Prove: & False
\end{tabular}
\begin{enumerate}[label=\bfseries Case \arabic*:,leftmargin=*]
\item It rains today.
\item It does not rain today.
\end{enumerate}
\end{document}
输出如下: