我希望枚举项列表中的每个项都有一个右对齐的名称。第三个项有很多文本。我希望名称位于两行文本之间。如果这被认为是印刷错误,我也想知道这一点。 这是一个 mwe。
\documentclass[paper=letter, 12pt]{scrbook}
\usepackage{amsmath, enumitem}
\begin{document}
A list.
\begin{enumerate}[itemsep=1pt]
\item Some condition. \hfill (condition 1)
\item Another condition. \hfill (condition 2)
\item A horribly long and convoluted, not to mention \hfill (condition 3)
\\ overly wordy condition.
\end{enumerate}
\end{document}
\end{document}
答案1
如果您有可能需要交叉引用一个或多个条件,我认为值得为这些条件设置一个定制的枚举类型列表类型。这可以借助包的机制轻松完成enumitem
(无论如何您都会加载它)。
\documentclass{scrbook}
\usepackage{enumitem,cleveref}
\newlist{condlist}{enumerate}{1} % create an enumerate-like list env.
\setlist[condlist]{left=0pt, itemsep=1pt, % define its properties
label=Condition \arabic*., ref=\arabic*}
\crefname{condlisti}{condition}{conditions}
\begin{document}
\begin{condlist}
\item Some condition. \label{cond:1}
\item Another condition. \label{cond:2}
\item A horribly long and convoluted, not to mention extremely dense and overly wordy condition.
\end{condlist}
A cross-reference to condition \ref{cond:1}.
Cross-references to \cref{cond:1,cond:2}.
\end{document}
答案2
当行很长时,最好将数字与名称对齐。在这种情况下,表格环境就足够了,并且可以简化代码。
nicematrix 的环境{NiceTabular*}
有自己的内置行计数器,称为iRow
。该命令 \Block
允许\\
在内部使用。
\documentclass[paper=letter, 12pt]{scrbook}
\usepackage{nicematrix}% only package needed <<
\begin{document}
A list. \medskip
\begin{NiceTabular*}{\linewidth}{>{\arabic{iRow}.}c l @{\extracolsep{\fill}}l}[cell-space-limits = 4pt]
& Some condition & (condition 1)\\
& Another condition. & (condition 2)\\
&\Block[l]{}{A horribly long and convoluted, not to mention \\ overly wordy condition.} & (condition 3)
\end{NiceTabular*}
\end{document}