我正在使用enumerate
(与包一起enumitem
)并想要制作如下例所示的列表。
Here is the first list:
1. Item 1.
2. Item 2.
etc.
Here is the second list:
(i) Item 1.
(ii) Item 2.
(iii) Item 3. This item is longer, to show how text should be aligned when it
wraps after the end of a line.
这是 MWE。设置labelindent
可实现所需的文本换行,但项目不会对齐。设置itemindent
可对齐项目,但会使文本换行混乱。
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\noindent First the result by setting ``labelindent". Here is the first list:
\begin{enumerate}[leftmargin=*, labelsep=1.0em, labelindent=\parindent,
itemsep=0.0em, topsep=0.5em, label=\arabic*.]
\item Item 1.
\item Item 2.
\end{enumerate}
Here is the second list:
\begin{enumerate}[leftmargin=*, labelsep=1.0em, labelindent=\parindent,
itemsep=0.0em, topsep=0.5em, label=(\roman*)]
\item Item 1.
\item Item 2.
\item Item 3. This item is longer, to show how text should be aligned when it
wraps after the end of a line.
\end{enumerate}
Notice how the items in the two lists are not the same distance from the left
margin.
Now the solution with by setting ``itemindent". Here is the first list:
\begin{enumerate}[labelsep=1.0em, itemindent=\parindent, itemsep=0.0em,
topsep=0.5em]
\item Item 1.
\item Item 2.
\end{enumerate}
Here is the second list:
\begin{enumerate}[labelsep=1.0em, itemindent=\parindent, itemsep=0.0em,
topsep=0.5em, label=(\roman*)]
\item Item 1.
\item Item 2.
\item Item 3. This item is longer, to show how text should be aligned when it
wraps after the end of a line.
\end{enumerate}
Notice how the text in the various items is the same distance from the left margin, except
in the last line of the last item.
\end{document}
答案1
我认为的使用widest*=somenumber
应该更好,结合特殊的列表克隆。
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\def\widestnumber{25}
\newlist{mylist}{enumerate}{1}
\setlist[mylist,1]{
leftmargin=40pt,
labelsep=1.0em, %labelindent=\parindent,
itemsep=0.0em,
topsep=0.5em,
label=\arabic*.,
widest*=\widestnumber}
\noindent First the result by setting "labelindent". Here is the first list:
\begin{mylist}
\item Item 1.
\item Item 2.
\end{mylist}
Here is the second list:
\begin{mylist}[label=(\roman*)]
\item Item 1.
\item Item 2.
\item Item 3. This item is longer, to show how text should be aligned when it
wraps after the end of a line.
\end{mylist}
Notice how the items in the two lists are not the same distance from the left
margin.
\end{document}