使用嵌套枚举时,如何让更长的标签从第一个环境的标签之后的相同位置开始?

使用嵌套枚举时,如何让更长的标签从第一个环境的标签之后的相同位置开始?

我希望能够在嵌套enumerate环境中使用长标签,而不会让它们与上一层重叠。我真的不知道如何正确解释这一点,所以这里有一个 MWE 来说明我想要什么。

\documentclass{article}
\usepackage[shortlabels]{enumitem}


\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
Stuff
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}

有人知道怎么做吗?

在此处输入图片描述

答案1

enumerate

您在上一个问题中说过,您宁愿不切换,enumitem而是继续使用enumerate这个套餐。

使用后者并添加

\setlength{\labelsep}{1em}

序言(正如我在您上一个问题中所说的那样)解决了这个问题。

平均能量损失

\documentclass{article}
\usepackage{enumerate}

\setlength{\labelsep}{1em}

\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
Stuff
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document} 

输出:

在此处输入图片描述


enumitem

相反,如果您已经切换到enumitem,则可以通过在序言中添加以下几行来解决问题:

\setlist[enumerate]{
  leftmargin=*
}

这样你修改后的 MWE

\documentclass{article}
\usepackage[shortlabels]{enumitem}

\setlist[enumerate]{
  leftmargin=*
}

\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
Stuff
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document} 

产量

在此处输入图片描述

答案2

如果是意外使用且特殊更改仍然存在:

\documentclass{article}
\usepackage[shortlabels]{enumitem}

\newlength{\LLwidth}
\settowidth{\LLwidth}{Long Label a)}


\begin{document}
\begin{enumerate}
\item
Hello
\begin{enumerate}
\item
Here is a normal enunerate with short labels.
\item
It looks pretty.
\item
I would like to have all of my labels ``start'' at the same place.
\item
That is to say, after the first label.
\end{enumerate}
\end{enumerate}


\begin{enumerate}
\item
Stuff
\leftmarginii\LLwidth
\begin{enumerate}[{Long Label} a)]
\item
Here is an enumerate with long lables.
\item
Notice that the labels start before the label of the containing enumerate environment.
\item
I find this undesirable.
\end{enumerate}
\end{enumerate}

\begin{enumerate}
\item
\leftmarginii\LLwidth
\begin{enumerate}[{Long Label} a)]
\item
As you can see, the issue becomes even more obvious when there is no content after the first label, so the labels actually overlap.
\end{enumerate}
\end{enumerate}
\end{document}

在此处输入图片描述

答案3

我不完全确定你想要什么,但如果只是嵌套的枚举环境总是比它们的父级“小”,那么这样做就可以了:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{showframe}% <-- just to give some perspective
\usepackage{enumitem}
  \setlist{labelindent=0pt, align=left}

\newlength\LLwidth
\settowidth{\LLwidth}{Long Label a}% <-- this is not good for consistency
\setlength{\LLwidth}{3cm}%           <-- this is better; but maybe pick a font-based value

\begin{document}

\noindent lksjdf

\begin{enumerate}
\item Hello
  \begin{enumerate}
  \item Here is a normal enunerate with short labels.
  \item It looks pretty.
  \item I would like to have all of my labels ``start'' at the same
    place.
  \item That is to say, after the first label.
  \end{enumerate}
\end{enumerate}


\begin{enumerate}
\item Stuff

  \begin{enumerate}[leftmargin=*, labelwidth={\LLwidth}, label={Long Label
      \alph*)}]

  \item Here is an enumerate with long lables.

  \item Notice that the labels start before the label of the containing
    enumerate environment.

  \setcounter{enumii}{12}%  <-- just to see a wider label in effect
  \item I find this undesirable.

  \end{enumerate}
\end{enumerate}

\begin{enumerate}
\item ~ % <-- prevent the overlap

  \begin{enumerate}[leftmargin=*, labelwidth={\LLwidth}, label={Long Label
      \alph*)}]

  \item As you can see, the issue becomes even more obvious when there
    is no content after the first label, so the labels actually overlap.
  \end{enumerate}

\end{enumerate}

\end{document}

如果您使用长标签做一堆奇怪的事情,我建议您使用功能\setlistenumitem保持列表环境中的一致性。

相关内容