enumerate 环境的普通用法如下:
Text above.
\begin{enumerate}
\item Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
产生如下输出:
Text above.
(1) Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
(2) Now is the time for all good men.
Text below.
但是,如果我在上使用自定义标签\item
,则标签的右端将放置在与标准标签相同的位置,如果标签有任何长度,则会产生较差的结果,将标签的左端推向边缘:
Text above.
\begin{enumerate}
\item[elephant] Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
Text above.
elephant Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
(2) Now is the time for all good men.
Text below.
是否有一个好的/简单的方法可以在项目上放置自定义标签,并将标签的左端与标准标签的左端对齐(根据需要将项目文本推到右侧)?
Text above.
elephant Now is the time for all good men. Now is the time for all
...
(2) Now is the time for all good men.
Text below.
答案1
enumitem
提供适合此布局的sameline
样式选项 ( style=sameline
)。可能需要进行一些额外的边距调整,如下例所示。
\documentclass{article}
\usepackage{enumitem}
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
Text above.
% Default layout
\begin{enumerate}[label=(\arabic*)]
\item Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
\hrulefill
Text above.
% Updated layout
\begin{enumerate}[label=(\arabic*),align=left,labelindent=0.7em,leftmargin=*,style=sameline]
\item[elephant]
Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
\end{document}
您可以创建一个新列表来捕捉这种风格:
\newlist{mylist}{enumerate}{1}% mylist matches enumerate up to 1 level of enumeration
\setlist[mylist]{
label=(\arabic*),
align=left,
labelindent=0.7em,
leftmargin=*,
style=sameline
}
这将允许您在文档中使用\begin{mylist}
...。\end{mylist}
答案2
我有一个粗略的解决方案,使用技巧将自定义标签设为空(以隐藏标准标签),将标签放在项目主体的开头,然后手动将标签缩进 2 em:
Text above.
\begin{enumerate}
\item[\hbox{}] \hskip -2em elephant The text. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men. Now is the time for all good men. Now is the time for all
good men.
\item Now is the time for all good men.
\end{enumerate}
Text below.
Text above.
elephant Now is the time for all good men. Now is the time for all
...
good men.
(2) Now is the time for all good men.
Text below.