如何使用labelsep创建与标签宽度不变的左对齐罗马数字列表?

如何使用labelsep创建与标签宽度不变的左对齐罗马数字列表?

我想要一个左边距等于 的列表\parindent,并且每个列表以等于 的缩进量开头\parindent,即第一个项目将缩进两倍\parindent。此外,列表将左对齐,并以罗马数字括起来。

我的 MWE 如下:

\documentclass{article}
\usepackage{enumitem}

\setlist{leftmargin=\parindent,
itemindent=\dimexpr\labelwidth+\labelsep+\parindent,
align=left,nosep,
listparindent=\parindent,
label={({\itshape\roman*}\,)},
labelsep=0pt}

\begin{document}

\section{First section}

Text before list, first paragraph. The sentence in first paragraph is The quick brown fox jumps over the lazy dog.

Text before list, second paragraph. The sentence in second paragraph is alpha beta gamma delta epsilon zeta eta omega.

\begin{enumerate}
    \item The first item first line. The sentence in first item is The quick brown fox jumps over the lazy dog.
    \item The second item first line. The sentence in second item is alpha beta gamma delta epsilon zeta eta omega.
\end{enumerate}

Text after list, first paragraph. The sentence in first paragraph is The quick brown fox jumps over the lazy dog.


\end{document}

输出结果如下:在此处输入图片描述

一切都很好,除了右括号和项目内容之间的间隔。第一个项目的间隙明显更大。我猜这是为了弥补项目标签宽度不同的事实。间隙的差异在第三个中更为明显,因为 (iii) 会更宽(此处未显示)。我希望所有项目与项目标签之间的距离都保持恒定。

我尝试过label=\mbox{({\itshape\roman*}\,)},但没有成功。

(编辑)我想要的是: 在此处输入图片描述

(编辑 2) 奇怪的是,fbox它似乎按照我的要求运行(除了盒子)。我以为除了盒子之外mbox,它fbox应该以同样的方式运行。在此处输入图片描述

答案1

我不确定你是否想设置全部列表是这样的,所以我建议创建一个新列表。您可以自由地将其用于每个列表,但是……

\documentclass{article}
\usepackage{enumitem}

\newlist{roster}{enumerate}{1}
\setlist[roster]{
  leftmargin=\parindent,
  labelwidth=0pt,
  itemindent=\dimexpr 0.5em+\parindent\relax,
  align=left,
  nosep,
  listparindent=\parindent,
  label={({\itshape\roman*}\,)},
  labelsep=0.5em,
}

\begin{document}

\section{First section}

Text before list, first paragraph. The sentence in first paragraph is 
The quick brown fox jumps over the lazy dog.

\hspace*{\parindent}Check double parindent

\begin{roster}
    \item The first item first line. The sentence in first item is 
          The quick brown fox jumps over the lazy dog.
    \item The second item first line. The sentence in second item is
          alpha beta gamma delta epsilon zeta eta omega.
\end{roster}

Text after list, first paragraph. The sentence in first paragraph is The quick brown fox jumps over the lazy dog.


\end{document}

诀窍是将标签宽度设置为零,并将项目缩进设置为\parindent加上标签间隔。

在此处输入图片描述

抱歉,但我认为这不太有吸引力。

答案2

我想你想要align=right。我也给了labelsep一个小值(2pt);

\documentclass{article}
\usepackage{enumitem}

\setlist{leftmargin=\parindent,
itemindent=\dimexpr\labelwidth+\labelsep+\parindent,
align=right,nosep,
listparindent=\parindent,
label={({\itshape\roman*}\,)},
labelsep=2pt}

\begin{document}

\section{First section}

Text before list, first paragraph. The sentence in first paragraph is The quick brown fox jumps over the lazy dog.

Text before list, second paragraph. The sentence in second paragraph is alpha beta gamma delta epsilon zeta eta omega.

\begin{enumerate}
    \item The first item first line. The sentence in first item is The quick brown fox jumps over the lazy dog.
    \item The second item first line. The sentence in second item is alpha beta gamma delta epsilon zeta eta omega.
\end{enumerate}

Text after list, first paragraph. The sentence in first paragraph is The quick brown fox jumps over the lazy dog.

\end{document} 

在此处输入图片描述

相关内容